Browse Source

Added a test for scheduler bindings.

Added a property which is updated on a b/g thead to BindingTest.
Steven Kirk 9 years ago
parent
commit
4c179634c1

+ 4 - 0
samples/BindingTest/MainWindow.xaml

@@ -41,6 +41,10 @@
             <TextBox Watermark="Value of first TextBox" UseFloatingWatermark="True" 
                      Text="{Binding #first.Text, Mode=TwoWay}"/>
           </StackPanel>
+          <StackPanel Margin="18" Gap="4" Width="200" HorizontalAlignment="Left">
+            <TextBlock FontSize="16" Text="Scheduler"/>
+            <TextBox Watermark="Background Thread" Text="{Binding CurrentTime, Mode=OneWay}"/>
+          </StackPanel>
         </StackPanel>
       </StackPanel>
     </TabItem>

+ 18 - 0
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<TestItem> 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<object> StringValueCommand { get; }
 
         public DataAnnotationsErrorViewModel DataAnnotationsValidation { get; } = new DataAnnotationsErrorViewModel();