Is it possible to detect Keyboard focus events globally?

后端 未结 4 1709
无人及你
无人及你 2021-02-19 12:45

The following events can be used, but, they must be attach for each element:

GotKeyboardFocus, LostKeyboardFocus

Is there a way in .NET WPF to globally detect if

4条回答
  •  -上瘾入骨i
    2021-02-19 13:28

    You can hook to the tunneling preview events:

    
    ....
    

    This way, as shown above, the window would be notified before all descendants when any of the descendants gets or loses the keyboard focus.

    Read this for more information.

提交回复
热议问题