Sfoglia il codice sorgente

Updated BindingTest sample view model

Wiesław Šoltés 9 anni fa
parent
commit
a3d2cc400d
1 ha cambiato i file con 12 aggiunte e 1 eliminazioni
  1. 12 1
      samples/BindingTest/ViewModels/MainWindowViewModel.cs

+ 12 - 1
samples/BindingTest/ViewModels/MainWindowViewModel.cs

@@ -11,6 +11,7 @@ namespace BindingTest.ViewModels
         private string _booleanString = "True";
         private double _doubleValue = 5.0;
         private string _stringValue = "Simple Binding";
+        private bool _booleanFlag = false;
 
         public MainWindowViewModel()
         {
@@ -31,7 +32,11 @@ namespace BindingTest.ViewModels
             });
 
             StringValueCommand = ReactiveCommand.Create();
-            StringValueCommand.Subscribe(param => StringValue = param.ToString());
+            StringValueCommand.Subscribe(param =>
+            {
+                BooleanFlag = !BooleanFlag;
+                StringValue = param.ToString();
+            });
         }
 
         public ObservableCollection<TestItem> Items { get; }
@@ -56,6 +61,12 @@ namespace BindingTest.ViewModels
             set { this.RaiseAndSetIfChanged(ref _stringValue, value); }
         }
 
+        public bool BooleanFlag
+        {
+            get { return _booleanFlag; }
+            set { this.RaiseAndSetIfChanged(ref _booleanFlag, value); }
+        }
+
         public ReactiveCommand<object> StringValueCommand { get; }
     }
 }