WPF KeyGestures-绑定非字母数字键 [英] WPF KeyGestures - Binding non alphanumeric keys

查看:382
本文介绍了WPF KeyGestures-绑定非字母数字键的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

应该很简单,但是我不知道该怎么做.我想使用WPF4绑定 Ctrl + -进行缩小,并绑定 Ctrl + = 进行放大:

Should be a simple one, but I can't work out how to do it. Using WPF4 I want to Bind Ctrl + - to Zoom Out and Ctrl + = to Zoom In:

    <KeyBinding Command="{Binding Content.ZoomInCommand}" Gesture="Ctrl+="/>
    <KeyBinding Command="{Binding Content.ZoomOutCommand}" Gesture="Ctrl+-"/>

但是,我遇到了错误:在 Ctrl + = 的情况下:

However, I'm getting errors: in the case of Ctrl + =:

找不到请求的值'='.

Requested value '=' was not found.

有什么想法吗?

推荐答案

好-事实证明 = 键不存在(您可以通过Key-枚举进行检查-在那里是 Equal EqualSign 的条目)...我使用的是国际键盘,因此您必须找到要输入 = (对我来说,这是丹麦键盘上的 Shift + D0 )-并使用该键序列.

Okay - it turns out that the = key does not exist (you can check this through the Key-enumeration - there is no entry for Equal or EqualSign)... I use an international keyboard, so you have to find which key sequence you hit to enter = (for me it's Shift + D0 on a danish keyboard) - and use that key-sequence.

因此您的XAML应该是(在丹麦):

So your XAML should be (in Denmark):

<KeyBinding Command="{Binding Content.ZoomInCommand}" Gesture="Ctrl+Shift+D0"/>

我相信在美国系统上,它是OemPlus键-但是您可以通过在按下事件处理程序中通过控制台写行输入e.Key参数来对其进行检查)

I believe on an American system it is the OemPlus key - but you can check it by console-writeline'ing the e.Key argument in a key-down event handler)

-键在我的系统上是OemMinus.

这篇关于WPF KeyGestures-绑定非字母数字键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆