Wpf System.Windows.Input.Key:xaml中的方括号?
使用XAML,我想声明一个带有修饰符=“Control”和Key=“[”的KeyBinding。字符“[”不是System.Windows.Input.Key枚举的一部分。如何在XAML中声明此KeyBinding?Wpf System.Windows.Input.Key:xaml中的方括号?,wpf,xaml,key-bindings,Wpf,Xaml,Key Bindings,使用XAML,我想声明一个带有修饰符=“Control”和Key=“[”的KeyBinding。字符“[”不是System.Windows.Input.Key枚举的一部分。如何在XAML中声明此KeyBinding?Key.oempenbrakets和Key.oemclosebrakets 刚刚用这个测试了一下: <Window.CommandBindings> <CommandBinding Command="Help" Executed="Help_Executed
Key.oempenbrakets
和Key.oemclosebrakets
刚刚用这个测试了一下:
<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;
}