Is it possible to detect Keyboard focus events globally?

后端 未结 4 2395
眼角桃花
眼角桃花 2021-02-19 12:52

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条回答
  •  忘掉有多难
    2021-02-19 13:29

    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.

提交回复
热议问题