14
I am learning MVVM and WPF. I have a xaml file in my project and which has a simple click event handler in the code behind.
Now I want to do the same in MVVM. I read a lot of articles and also read many answers in sof. But still unable to do this.
Can anyone please give a simple example in which a button click event is done in MVVM.
Edit
<Window x:Class="WhiteBalance.BaseCalWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:uc="clr-namespace:NumberUpDownControl;assembly=NumberUpDownControl"
xmlns:viewn="clr-namespace:WhiteBalance.ViewModels"
Title="RefImgSettingWindow" Height="900" Width="1000" ResizeMode="NoResize"
BorderThickness="4">
<Window.Resources>
<viewn:DashBoardViewModel x:Key="demokey"></viewn:DashBoardViewModel>
</Window.Resources>
<Grid x:Name="gdParent" DataContext="{StaticResource demokey}">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="490" />
<ColumnDefinition Width="488*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="300" />
<RowDefinition Height="300" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<StackPanel Grid.Row="0" Grid.Column="0">
<Label Content="{Binding Path=NAME,Mode=TwoWay}" Height="28" Name="lblTest" />
<Button Content="Capture" Height="23" Name="btnCapture" Width="75" Command="{Binding Path=SaveCommand}"
Canvas.Left="94" Canvas.Top="254" />
</StackPanel>
</Grid>
</Window>
namespace WhiteBalance.ViewMo