开发者

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:

Command Inputbindings work but Shortcut does not show in MenuItem

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" />
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜