I'm new to SilverLight and Mvvm-Light. I have a DataForm on my view that displays/edits a SelectedPerson property (a Person object) of my view model.
I want to execute a command on my viewmodel when the user clicks the Save button but don't want to take action if the user clicks cancel.
I added the following to my ViewModel:
public RelayCommand PersonEditEnded {get; set;}
...
public void Initialize()
{
PersonEditEnded = new RelayCommand(DoSomething);
...
}
public void DoSomething()
{
}
I added the following to my View:
<toolkit:DataForm x:Name="PersonForm" ... CurrentItem="{Binding SelectedPerson, Mode=TwoWay}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="EditEnded">
<gs:EventToCommand Command="{Binding PersonEditEnded, Mode=OneWay}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</toolkit:DataForm>
This works and the DoSomething method is being called when the user presses Submit. However, DoSomething is also called when user presses Cancel. Is there a way to know which button was pressed or to supress the call when Cancel is pressed?
Thanks for whatever help you can offer!