命令输入绑定有效,但快捷方式未显示在菜单项中

发布于 2024-10-06 04:16:47 字数 949 浏览 0 评论 0原文

问:

我正在使用 Josh Smith 的 使用路由命令实现 MVVM 的命令 。我有一个绑定到命令的 MenuItem

输入绑定在父窗口中定义。当我运行程序时,我可以使用键盘快捷键,但MenuItem旁边不显示Control+O MenuItem 标头。

图片:

Ctrl+O 在哪里?

代码:

命令绑定:

 <Window.CommandBindings>
    <cmd:CommandSinkBinding Command="vm:MainVM.OpenDialogCommand" />
</Window.CommandBindings>

<Window.InputBindings>
    <KeyBinding Command="vm:MainVM.OpenDialogCommand" Key="O" Modifiers="Ctrl"/>
</Window.InputBindings>

菜单项:

<MenuItem Header="Open" Command="vm:MainVM.OpenDialogCommand" />

注意: 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:

Where is the Ctrl+O?

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

白龙吟 2024-10-13 04:16:47

试试这个

<MenuItem Header="Open" Command="vm:MainVM.OpenDialogCommand" 
       InputGestureText="Ctrl+O" />

try this

<MenuItem Header="Open" Command="vm:MainVM.OpenDialogCommand" 
       InputGestureText="Ctrl+O" />
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文