fork download
  1. //MainWindow.xaml.cs usingディレクティブ省略
  2. namespace TestWPF {
  3. public partial class MainWindow : Window {
  4. private Data data = new Data("aaa");
  5. public MainWindow() {
  6. InitializeComponent();
  7. DataContext = data;
  8. DispatcherTimer timer = new DispatcherTimer();
  9. timer.Tick += new EventHandler(timer_Tick);
  10. timer.Interval = new TimeSpan(0, 0, 1);
  11. timer.Start();
  12. }
  13. void timer_Tick(object sender, EventArgs e) {
  14. data.BindingText = "bbb"; // (*)
  15. }
  16. }
  17. public class Data {
  18. public string BindingText { set; get; }
  19. public Data(string bt) {
  20. this.BindingText = bt;
  21. }
  22. }
  23. }
  24.  
  25. //MainWindow.xaml
  26. <Window x:Class="TestWPF.MainWindow"
  27. xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  28. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
  29.  Title="MainWindow" Height="350" Width="525">
  30. <TextBlock Text="{Binding Path=BindingText}" Name="BlockName"/>
  31. </Window>
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty