Karnalta
Karnalta

Reputation: 538

WPF Window GotFocus / LostFocus

I have a simple task to accomplish, or at least in appearance ...

I'd like to handle the fact that a window is currently the current selected window in the Windows environment or not.

I thought I had just to handle the two event LostFocus and GotFocus of my window, but they don't fired. I can select the window or click elsewhere on the desktop, none of the events are triggered..

The GotFocus event only fired when I reduce or maximize the window.

Am I doing something wrong ?

Thank you.

Upvotes: 5

Views: 6570

Answers (1)

Florian Gl
Florian Gl

Reputation: 6014

Try using the Activated/Deactivated event. GotFocus/LostFocus is intended to be used only with controls (e.g. it fires when you click on controls inside the window).

Upvotes: 15

Related Questions