I tried DelegateCommand approach, it executes properly, but my key gestures do not work:
public DelegateCommand StageCommand { get; private set; }
...
StageCommand = new DelegateCommand(StageExecuted);
...
private void StageExecuted(object action)
{
System.Console.WriteLine("yay!");
}
And XAML for my Context Menu:
<ContextMenu.InputBindings>
<KeyBinding Command="{Binding PlacementTarget.Tag.StageCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}"
Gesture="Enter" />
</ContextMenu.InputBindings>
<MenuItem Header="Stage" Command="{Binding PlacementTarget.Tag.StageCommand, RelativeSource={RelativeSource AncestorType=ContextMenu}}">
</MenuItem>
All this executes properly, but I am missing the key gesture, it does not even display it:

This is how I use the context menu:
<DataGrid
ContextMenu="{DynamicResource TestContextMenu}"
Tag="{Binding}">
Update:
If I press Enter while the context menu is open, it executes. How can I make it so that it executes as long as the control that has the context menu attached to it has focus? And also, it still does not display the gesture key.
From MSDN for
MenuItem.InputGestureText:Basically, because that is purely a text field for displaying an input gesture to users in the default
MenuItemControl Template there is no association between it and some command you’ve decided to wire-up with aKeyBinding.You could handle this through a binding, or a
StaticResource, or maybe thru an attached property/behavior which searches theKeyBindings and assigns input gestures to any child which uses the matching command.