From 4c179634c1765fd3c23bd4862da6be00f7a4fd7e Mon Sep 17 00:00:00 2001 From: Steven Kirk Date: Thu, 3 Nov 2016 21:10:16 +0100 Subject: [PATCH] Added a test for scheduler bindings. Added a property which is updated on a b/g thead to BindingTest. --- samples/BindingTest/MainWindow.xaml | 4 ++++ .../ViewModels/MainWindowViewModel.cs | 18 ++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/samples/BindingTest/MainWindow.xaml b/samples/BindingTest/MainWindow.xaml index 02c364346d..95f671fd84 100644 --- a/samples/BindingTest/MainWindow.xaml +++ b/samples/BindingTest/MainWindow.xaml @@ -41,6 +41,10 @@ + + + + diff --git a/samples/BindingTest/ViewModels/MainWindowViewModel.cs b/samples/BindingTest/ViewModels/MainWindowViewModel.cs index 94f7ff595a..4b58bf2279 100644 --- a/samples/BindingTest/ViewModels/MainWindowViewModel.cs +++ b/samples/BindingTest/ViewModels/MainWindowViewModel.cs @@ -3,6 +3,8 @@ using System.Collections.ObjectModel; using System.Linq; using ReactiveUI; using System.Reactive.Linq; +using System.Threading.Tasks; +using System.Threading; namespace BindingTest.ViewModels { @@ -12,6 +14,7 @@ namespace BindingTest.ViewModels private double _doubleValue = 5.0; private string _stringValue = "Simple Binding"; private bool _booleanFlag = false; + private string _currentTime; public MainWindowViewModel() { @@ -37,6 +40,15 @@ namespace BindingTest.ViewModels BooleanFlag = !BooleanFlag; StringValue = param.ToString(); }); + + Task.Run(() => + { + while (true) + { + CurrentTime = DateTimeOffset.Now.ToString(); + Thread.Sleep(1000); + } + }); } public ObservableCollection Items { get; } @@ -67,6 +79,12 @@ namespace BindingTest.ViewModels set { this.RaiseAndSetIfChanged(ref _booleanFlag, value); } } + public string CurrentTime + { + get { return _currentTime; } + private set { this.RaiseAndSetIfChanged(ref _currentTime, value); } + } + public ReactiveCommand StringValueCommand { get; } public DataAnnotationsErrorViewModel DataAnnotationsValidation { get; } = new DataAnnotationsErrorViewModel();