I am new to SilverLight and Mvvm-Light. I have a DataForm on my view that displays / edits the SelectedPerson property (Person object) of my view model.
I want to execute a command on my view model when the user clicks the Save button, but doesn’t want to take action if the user clicks the Cancel button.
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 called when the user clicks Submit. However, DoSomething is also called when the user clicks Cancel. Is there a way to find out which button was pressed or to suppress a call when the Cancel button is pressed?
, !