下面是我尝试为菜单项分配快捷方式的内容。当我单击菜单项时,它运行良好,但快捷方式不起作用。任何想法?
<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) {...}