I'm required to fire a command on the click of an item of my ListView. The Event is present in the ViewModel and should not be implemented in the code behind.
I'm currently handling it by using an EventSetter with the command being in the code behind, but I need it in ViewModel.
In short, I want to change the values of property1 and property2 (present in the ViewModel) as soon as I click on a item of the list.
Please help?
XAML:
<ListView.ItemContainerStyle>
<Style TargetType= "ListViewItem">
<EventSetter Event="PreviewMouseLeftButtonDown" Handler="MyCommand"/>
</Style>
</ListView.ItemContainerStyle>
CODE BEHIND:
private voide MyCommand(object sender, MouseButtonEventArgs e)
{
ViewModel.property1 = true;
ViewModel.property2 = false;
}