The following events can be used, but, they must be attach for each element:
GotKeyboardFocus, LostKeyboardFocus
Is there a way in .NET WPF to globally detect if
You can do this in any class with this:
//In the constructor
EventManager.RegisterClassHandler(
typeof(UIElement),
Keyboard.PreviewGotKeyboardFocusEvent,
(KeyboardFocusChangedEventHandler)OnPreviewGotKeyboardFocus);
...
private void OnPreviewGotKeyboardFocus(object sender,
KeyboardFocusChangedEventArgs e)
{
// Your code here
}