FocusLost event is working on WPF’s components properly
For User-Controls it is different:
if any control in the User-Control is clicked or focused, the User-Control’s FocusLost is fired immediately ! How can I hinder it ?
I could not solve this problem 🙁
You can check
IsKeyboardFocusWithinon theUserControlto determine if theUserControlor any of its children has the KeyBoard focus or not. There is also the eventIsKeyboardFocusWithinChangedwhich you can use, just check ife.OldValueistrueande.NewValueisfalsein the event handler.Edit.
Here is an example of how you could make the
UserControlraise a routed event (UserControlLostFocus) whenIsKeyboardFocusWithinturns to false.Useable like
Sample
UserControl