Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WPF Window GotFocus / LostFocus

Tags:

focus

window

wpf

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.

like image 827
Karnalta Avatar asked Feb 21 '13 09:02

Karnalta


1 Answers

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).

like image 165
Florian Gl Avatar answered Oct 12 '22 07:10

Florian Gl