I need help to get Selected list view item details, when context menu assigned to list view items is clicked.
<ListView.Resources>
<ContextMenu x:Key="GvRowMenu" ItemsSource="{Binding ContextMenuItems}">
<ContextMenu.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Source="{Binding IconPath}"></Image>
<TextBlock Text="{Binding Name}"></TextBlock>
<MenuItem
Click="MenuItem_Click"
CommandParameter="{Binding RelativeSource={RelativeSource Self}, Path=DataContext.RunCommand}" />
This is a click event code
private void MenuItem_Click(object sender, RoutedEventArgs e)
{
//what needs to de here?
}
I wrote this piece of code in my view model, but it doesnt trigger on execute method
RunCommand = new DelegateCommand<object>(OnRunCommand, CanRunCommand);
private void OnRunCommand(object obj)
{
// use the object here...
}
private bool CanRunCommand(object obj)
{
return true;
}
Let me know, how can I handle this situation. Any examples related to same will be appreciated.
Thanks