Browse Source

Update BindingDemo Sample

Giuseppe Lippolis 5 years ago
parent
commit
5d8c09c470

+ 1 - 0
samples/BindingDemo/MainWindow.xaml

@@ -116,6 +116,7 @@
         <RadioButton Content="Radio Button" IsChecked="{Binding !!BooleanFlag, Mode=OneWay}" Command="{Binding StringValueCommand}" CommandParameter="RadioButton"/>
         <TextBox Text="{Binding Path=StringValue}"/>
         <Button Content="Nested View Model Button" Name="NestedTest" Command="{Binding NestedModel.Command}" />
+        <Button Content="Command Method Do" Command="{Binding Do}" x:Name="ToDo"/>
       </StackPanel>
     </TabItem>
   </TabControl>

+ 12 - 0
samples/BindingDemo/ViewModels/MainWindowViewModel.cs

@@ -7,6 +7,7 @@ using System.Threading.Tasks;
 using System.Threading;
 using ReactiveUI;
 using Avalonia.Controls;
+using Avalonia.Metadata;
 
 namespace BindingDemo.ViewModels
 {
@@ -102,5 +103,16 @@ namespace BindingDemo.ViewModels
             get { return _nested; }
             private set { this.RaiseAndSetIfChanged(ref _nested, value); }
         }
+
+        public void Do(object parameter)
+        {
+
+        }
+
+        [DependsOn(nameof(BooleanFlag))]
+        bool CanDo(object parameter)
+        {
+            return BooleanFlag;
+        }
     }
 }