Command Inputbindings work but Shortcut does not show in MenuItem
Question:
I'm using Josh Smith's implementation of commands for MVVM using routed commands. I开发者_如何转开发 have a MenuItem
binded to a command.
The input bindings are defined in the parent window. When I run the program, I can use the Keyboard shortcut, but the MenuItem
does not show a Control+O
next to the MenuItem
header.
Pics:
Code:
Command Bindings:
<Window.CommandBindings>
<cmd:CommandSinkBinding Command="vm:MainVM.OpenDialogCommand" />
</Window.CommandBindings>
<Window.InputBindings>
<KeyBinding Command="vm:MainVM.OpenDialogCommand" Key="O" Modifiers="Ctrl"/>
</Window.InputBindings>
Menu Item:
<MenuItem Header="Open" Command="vm:MainVM.OpenDialogCommand" />
Note: The MenuItem is styled, but removing the style does not make a difference.
try this
<MenuItem Header="Open" Command="vm:MainVM.OpenDialogCommand"
InputGestureText="Ctrl+O" />
精彩评论