Disabling global KeyBindings in some controls in wpf c#

爱⌒轻易说出口 提交于 2019-12-23 19:11:04

问题


I have a main window with some keybindings like this:

<Window.InputBindings>
  <KeyBinding Command="{Binding RotateCommand}"
              CommandParameter="left"
              Key="L">
  </KeyBinding>
  <KeyBinding Command="{Binding RotateCommand}" 
              CommandParameter="right"
              Key="R" />
</Window.InputBindings>

The problem is that I am unable to type this letters in any textboxes in that window, keys L and R just call commands.

Is there any way to disable KeyBindings inside of some controls? (Maybe when some controls have a focus).

I search through the internet and find this, but I can't get access to CanExecute routed event because I'm using mvvm model for command bindings.

来源:https://stackoverflow.com/questions/28393307/disabling-global-keybindings-in-some-controls-in-wpf-c-sharp

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