下面是我试图为菜单项分配快捷方式。当我点击菜单项时效果很好,但快捷方式不起作用。任何想法?菜单项快捷方式
<Window.CommandBindings>
<CommandBinding Command="ApplicationCommands.Save" Executed="MyCommand" />
</Window.CommandBindings>
<Window.InputBindings>
<KeyBinding Key="S" Modifiers="Control" Command="ApplicationCommands.Save"/>
</Window.InputBindings>
<MenuItem Header="Save" Name="MainMenu_File_Save" Command="ApplicationCommands.Save">
<MenuItem.Icon>
<Image Height="16" Width="16" Source="/NewGUI_WPF;component/Images/saveHS.png" />
</MenuItem.Icon>
</MenuItem>
private void MyCommand(object sender, ExecutedRoutedEventArgs e) {...}
伟大的问题。它已经在这里回答http://stackoverflow.com/questions/4682915/defining-menuitem-shortcuts – 2012-04-10 18:16:01
我知道这个链接。但我仍然无法找到我的错误。 – Shibli 2012-04-10 18:28:45
你可以将整个xaml和代码放在后面吗?至于我一切正常。也许其他内部使用相同的命令? – 2012-04-10 18:52:17