How to get the focused control in WPF?

后端 未结 2 1598
名媛妹妹
名媛妹妹 2021-01-13 07:03

How can I get a current focused control in WPF?

I found some solution for WinForms, but invoking WIN32 API function, didn\'t work in WPF?

Is there any way fo

2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-13 07:49

    I know this is a late answer, but maybe people searching can find this helpful, I it found on msdn in the "Navigating Focus Programmatically" section close to the bottom of the page:

    UIElement elementWithFocus = Keyboard.FocusedElement as UIElement;
    

提交回复
热议问题