Multiples Keys in KeyBinding?

倖福魔咒の 提交于 2019-12-08 09:09:56

问题


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>

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>

Don't work.

<KeyBinding Gesture="Ctrl+B+A" Command="{Binding Source={StaticResource localCusomCommands}, Path=AddTTRowCommand}" ></KeyBinding>

Don't compile. Error 15 Unrecognized ModifierKeys 'B'.

How to achieve this?


回答1:


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



来源:https://stackoverflow.com/questions/28483141/multiples-keys-in-keybinding

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!