键绑定中有多个键? [英] Multiple Keys in KeyBinding?
问题描述
我想在Wpf应用程序中设置热键.在最简单的情况下,使用键绑定是可行的,例如: Ctrl + B , Ctrl + A 等>
I want to setup hotkeys in my Wpf application. Using KeyBindings works in the simple case, for example: Ctrl+B, Ctrl+A, etc
<KeyBinding Gesture="Ctrl+B" Command="{Binding Source={StaticResource localCusomCommands}, Path=AddTTRowCommand}" ></KeyBinding>
<KeyBinding Modifiers="Control" Key="B" Command="{Binding Source={StaticResource localCusomCommands}, Path=AddTTRowCommand}" ></KeyBinding>
但是如果我需要带有多个键的热键 Ctrl + P + B ,则 Ctrl + A + B ,等等
But if I need hotkeys with multiple keys Ctrl+P+B, Ctrl+A+B, etc
<KeyBinding Modifiers="Control" Key="P,B" Command="{Binding Source={StaticResource localCusomCommands}, Path=AddTTRowCommand}" ></KeyBinding>
不工作.
<KeyBinding Gesture="Ctrl+B+A" Command="{Binding Source={StaticResource localCusomCommands}, Path=AddTTRowCommand}" ></KeyBinding>
不编译.错误15无法识别的ModifierKey'B'.
如何实现?
推荐答案
正如我所讲的,有一个实现可以重写多个键的KeyBinding和Gestures.请参考下面的链接.他已经覆盖了InputGesture的实现来实现此多键绑定. http://kent-boogaart.com/blog/multikeygesture
As i told, there is implementation for overriding the KeyBinding and Gestures for multiple keys. refer the below link. He has overriden the implemetation of InputGesture to achieve this multikeybinding. http://kent-boogaart.com/blog/multikeygesture
这篇关于键绑定中有多个键?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!