Wednesday, April 18, 2012

Firing context menu from user control does not work

I try to use a context menu from a user control's list view but the command is not firing (neither enabling/disabling when needed).


<UserControl ....
<ContextMenu x:Key="SharedInstanceContextMenu">
<MenuItem Header="Edit" Command="{Binding ElementName=UC, Path=DataContext.EditSelectedItemCommand}" CommandParameter="{Binding}"/>

<Grid ...>
<ListView ....>
<Style TargetType="ListViewItem">
<Setter Property="IsSelected" Value="{Binding Path=IsSelected}"/>
<Setter Property="ContextMenu" Value="{StaticResource SharedInstanceContextMenu}"/>

How can I make the command firing (and enabling/disabling, part of the command behavior)?

(btw, this questions seems similar to Treeview context menu command not firing but after trying all solutions there it still does not work.)

No comments:

Post a Comment