//MainWindow.xaml.cs usingディレクティブ省略
namespace TestWPF {
public partial class MainWindow : Window {
private Data data = new Data("aaa");
public MainWindow() {
InitializeComponent();
DataContext = data;
DispatcherTimer timer = new DispatcherTimer();
timer.Tick += new EventHandler(timer_Tick);
timer.Interval = new TimeSpan(0, 0, 1);
timer.Start();
}
void timer_Tick(object sender, EventArgs e) {
data.BindingText = "bbb"; // (*)
}
}
public class Data {
public string BindingText { set; get; }
public Data(string bt) {
this.BindingText = bt;
}
}
}
//MainWindow.xaml
<Window x:Class="TestWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<TextBlock Text="{Binding Path=BindingText}" Name="BlockName"/>
</Window>
Ly9NYWluV2luZG93LnhhbWwuY3MgdXNpbmfjg4fjgqPjg6zjgq/jg4bjgqPjg5bnnIHnlaUKbmFtZXNwYWNlIFRlc3RXUEYgewogICAgcHVibGljIHBhcnRpYWwgY2xhc3MgTWFpbldpbmRvdyA6IFdpbmRvdyB7CiAgICAgICAgcHJpdmF0ZSBEYXRhIGRhdGEgPSBuZXcgRGF0YSgiYWFhIik7CiAgICAgICAgcHVibGljIE1haW5XaW5kb3coKSB7CiAgICAgICAgICAgIEluaXRpYWxpemVDb21wb25lbnQoKTsKICAgICAgICAgICAgRGF0YUNvbnRleHQgPSBkYXRhOwogICAgICAgICAgICBEaXNwYXRjaGVyVGltZXIgdGltZXIgPSBuZXcgRGlzcGF0Y2hlclRpbWVyKCk7CiAgICAgICAgICAgIHRpbWVyLlRpY2sgKz0gbmV3IEV2ZW50SGFuZGxlcih0aW1lcl9UaWNrKTsKICAgICAgICAgICAgdGltZXIuSW50ZXJ2YWwgPSBuZXcgVGltZVNwYW4oMCwgMCwgMSk7CiAgICAgICAgICAgIHRpbWVyLlN0YXJ0KCk7CiAgICAgICAgfQogICAgICAgIHZvaWQgdGltZXJfVGljayhvYmplY3Qgc2Vu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