WPF: How to prevent a control from stealing a key gesture?

后端 未结 3 1836
有刺的猬
有刺的猬 2021-01-04 04:50

In my WPF application I would like to attach an input gesture to a command so that the input gesture is globally available in the main window, no matter which control has th

3条回答
  •  没有蜡笔的小新
    2021-01-04 05:22

    Unfortunately in WPF some controls have some keyboard processing hardcoded internally. The PreviewKeyDown handler in the main window is the answer to

    How can I define a keyboard shortcut that works everywhere in the main window

    question. And yes, it does mean that you may want to choose switch/case on the key events in the PreviewKeyDown manually...

提交回复
热议问题