Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get notified when a window get focus in WPF?

Tags:

focus

wpf

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?

like image 241
Fossmo Avatar asked Aug 01 '09 19:08

Fossmo


2 Answers

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.

like image 58
Kenan E. K. Avatar answered Sep 28 '22 06:09

Kenan E. K.


Use Activated event instead of GotFocus.

like image 37
maciejkow Avatar answered Sep 28 '22 07:09

maciejkow