对于没有进入等于在System.Windows.Input.Key枚举密钥? [英] No entry for the Equals key in the System.Windows.Input.Key enum?
问题描述
我想设置一个 InputGesture
在 RoutedUICommand
,挂钩起来赶上当用户presses 按Ctrl + =
。我使用的是 KeyGesture
的对象,但我不能看到 System.Windows.Input.Key
枚举了等号(=)键。
I'm trying to set an InputGesture
on a RoutedUICommand
, hooking it up to catch when the user presses Ctrl + =
. I'm using a KeyGesture
object, but I can't see an entry in the System.Windows.Input.Key
enum for the equals ('=') key.
我的期待是能够做到以下几点:
What I was expecting was to be able to do the following:
ZoomIn = new RoutedUICommand("Zoom In", "ZoomIn", typeof(Window),
new InputGestureCollection {
new KeyGesture(Key.Equals, ModifierKeys.Control)
});
任何人都可以点我朝着正确的方向吗?
Can anyone point me in the right direction, please?
推荐答案
正如刚才ChrisF,我需要搞我的大脑一点点。对于它的价值,价值在处理的KeyDown
事件是 Key.OemPlus
。
As pointed out by ChrisF, I needed to engage my brain a little. For what it's worth, the value generated when handling the KeyDown
event is Key.OemPlus
.
更新:
这样做的一个后果是,如果你正在做的一样一样的我,你要在菜单中的命令,你可能会想使用重载的构造函数 KeyGesture
这需要 displayString
。例如:
Update:
One consequence of this is that, if you're doing the same same as me and you're going to use the command in a menu, you'll probably want to use the overloaded constructor for KeyGesture
that takes a 3rd parameter of displayString
. For example:
new KeyGesture(Key.Equals, ModifierKeys.Control, "Ctrl+=")
否则,你会看到显示为快捷键(在我的情况),CTRL + OemPlus,这是不完全不可取的。诚然,以上还不是很大,但它比OemPlus更好。
Otherwise, you'll see the keyboard shortcut displayed as (in my case) "Ctrl+OemPlus", which isn't exactly desirable. Admittedly, the above still isn't great, but it's better than "OemPlus".
这篇关于对于没有进入等于在System.Windows.Input.Key枚举密钥?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!