I want to make some shortcuts for my Menu
in WPF. I made a static class with RoutedCommands
but I can't get it to work. It says that my markup is invalid, but I wrote everything fine. The error I get is: 'None+D6' key and modifier combination is not supported for KeyGesture. I haven't used D6 anywhere in my RoutedCommands
.
Relevant XAML
Window x:Class="WorldResources.GlowingEarth"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:cmd="clr-namespace:WorldResources.View"/>
<Window.CommandBindings>
<CommandBinding Command="cmd:RoutedCommands.NewMap" Executed="NewFile_Click" />
</Window.CommandBindings>
<DockPanel>
<Menu DockPanel.Dock="Top">
<Menu.ItemsPanel>
<ItemsPanelTemplate>
<DockPanel HorizontalAlignment="Stretch"></DockPanel>
</ItemsPanelTemplate>
</Menu.ItemsPanel>
<MenuItem Header="File">
<MenuItem Header="New">
<MenuItem Header="_Map" Command="cmd:RoutedCommands.NewMap" />
</MenuItem>
</Menu>
</DockPanel>
And here is my RoutedCommands
class
static class RoutedCommands
{
public static RoutedUICommand NewMap = new RoutedUICommand(
"New Map",
"NewMap",
typeof(RoutedCommands),
new InputGestureCollection()
{
new KeyGesture(Key.M & Key.A, ModifierKeys.Control & ModifierKeys.Shift)
}
);
}
What could be the problem?