15

I want to get notified when I click a window in WPF (I use the GotFocus event), but it only triggers when I click on a Combobox in the window. What I want is to get notified when the the window or any of the controls in the window is clicked. Any ideas of how to do this?

3 Answers 3

29

The GotFocus event doesn't get fired when the Window gets focus, it's intended to be used with controls only. The Activated event serves this particular purpose.

9

Use Activated event instead of GotFocus.

1

You could try the IsKeyboardFocusWithinChanged event. It should trigger when the keyboard focus is taken by an element of the window, or when it is taken by another window

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.