ObservableProperty Binding

master
Yik Teng Hie 3 years ago
parent d3b87a10a3
commit aa2832cb9c

@ -11,6 +11,9 @@
<TextBlock Text="{Binding Title}" /> <TextBlock Text="{Binding Title}" />
<Button Content="Add" <Button Content="Add"
Command="{Binding AddCommand}" /> Command="{Binding AddCommand}" />
<Button Content="Update"
Command="{Binding UpdateCommand}" />
<TextBlock Text="{Binding Customer}" />
</StackPanel> </StackPanel>
</Grid> </Grid>
</Window> </Window>

@ -8,6 +8,9 @@ namespace MvvmCommunityApp.viewmodels
{ {
public string Title { get; set; } public string Title { get; set; }
[ObservableProperty]
private string _customer;
public MainWindowViewModel() public MainWindowViewModel()
{ {
Title = "MyIocName"; Title = "MyIocName";
@ -19,5 +22,11 @@ namespace MvvmCommunityApp.viewmodels
{ {
Console.WriteLine("Do Add"); Console.WriteLine("Do Add");
} }
[RelayCommand]
private void Update()
{
Customer = "New Customer";
}
} }
} }

Loading…
Cancel
Save