I am working on a WPF project, and I am trying to fire an event every time some userControls get active or inactive.
These userControls have many other controls inside of them.
I tried to achieve this using the userControl events GotFocus and LostFocus, but these events are not working in the way I need since the userControl loses the focus when I work with controls inside of it.
So, my question is: Is there a way to mantain a userControl as Active while the user works with controls inside of it, and, when the user goes to another userControl this first one gets Inactive???
Thank you in advance.
I could solve my problem thank to the comments of @LPL and @Rachel.
I had to use the event UIElement.IsKeyboardFocusWithinChanged and it worked perfectly.
At first I had a problem which was that the callback method was being raised infinitely, but the actual problem was that I was showing a MessageBox every time the event IsKeyboardFocusWithinChanged raised, so, this caused that the IsKeyboardFocusWithin property changed and it created an infinite loop. But thanks to Rachel's advice I could figure out how to solve it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With