Using XAML, I want to declare a KeyBinding开发者_开发问答 with Modifiers="Control" and Key="[". The '[' character is not part of the System.Windows.Input.Key enum. How can I declare this KeyBinding in XAML?
Key.OemOpenBrackets
& Key.OemCloseBrackets
Just tested it with this:
<Window.CommandBindings>
<CommandBinding Command="Help" Executed="Help_Executed" CanExecute="Help_CanExecute"/>
</Window.CommandBindings>
<Window.InputBindings>
<KeyBinding Key="OemOpenBrackets" Command="Help" Modifiers="Control"/>
</Window.InputBindings>
private void Help_Executed(object sender, ExecutedRoutedEventArgs e)
{
MessageBox.Show("!");
}
private void Help_CanExecute(object sender, CanExecuteRoutedEventArgs e)
{
e.CanExecute = true;
}
Works for me with or without modifier, possibly the control you declared the binding on is out of focus. Another cause might be the keyboard layout, but i am not sure how the keys are resolved.
精彩评论