I need a simple way to set a shortcut for menu items.
But this don´t work with shortcut, just with click:
H.B. was right... I just wanted to add more precisions.
Remove the Click event on your MenuItem and associate it with a Command instead.
1 - Add/create your commands:
The commands are refering to the following code:
private void OpenCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
Open();//Implementation of open file
}
private void SaveAsCommandBinding_Executed(object sender, ExecutedRoutedEventArgs e)
{
SaveAs();//Implementation of saveAs
}
2 - Associate the commands with the wanted keys:
3 - Finally assign the commands with you menu item (InputGestureText is just a decorating text):
That way multiple inputs may be associated to the same command.