gpt4 book ai didi

Ctrl + Shift +零的WPF KeyBinding Guesture不起作用

转载 作者:行者123 更新时间:2023-12-01 11:56:38 25 4
gpt4 key购买 nike

我正在尝试使用 WPF 3.5sp1 映射 Ctrl+Shift+0,但绑定(bind)不会触发。我使用的 XAML 是:

<KeyBinding Gesture="Ctrl+Shift+D0" Command="Blah"/>

我也试过:
<KeyBinding Key="D0" Modifiers="Ctrl+Shift" Command="Blah" />

以及许多其他组合,但都不起作用。 Gesture="Ctrl+D0"效果很好,或者“Ctrl+Shift+OemPlus”等,所以我认为我的语法不是问题。我查看了 Key 枚举并试图查看“Shift-D0”是否被重新映射为“OemParen”之类的东西,但没有任何东西跳出来。

我什至在我的窗口上放了一个 PreviewKeyDown 处理程序,但我从来没有看到 KeyEvent 的 Key == D0 和 Keyboard.ModifierKeys == Shift + Ctrl!事实上,当我按住 Ctrl+Shift 时,D0 按键根本就不会出现。
public MainWindow()
{
InitializeComponent();
this.PreviewKeyDown += MainWindow_PreviewKeyDown;
}

void MainWindow_PreviewKeyDown(object sender, KeyEventArgs e)
{
if ((Keyboard.Modifiers & ModifierKeys.Shift) != 0)
{
Trace.WriteLine("shift is down!");
}
Trace.WriteLine(string.Format("key: {0}, system key: {1}, modifiers {2}", e.Key, e.SystemKey, e.KeyStates));
}

最佳答案

我发现了问题。罪魁祸首是在 Vista(Win7 继承)中进行的与键盘布局更改方式相关的国际化更改。有一个KB topic讨论这个问题和解决方法:

Input method editor keyboard shortcut (CTRL+SHIFT+0) switches the input language in Vista

关于Ctrl + Shift +零的WPF KeyBinding Guesture不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6472273/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com