Code Snippet
public partial class Window1 : Window
{
static Window1()
{
EventManager.RegisterClassHandler(
typeof(UIElement),
Keyboard.LostKeyboardFocusEvent,
new KeyboardFocusChangedEventHandler(OnKeyboardEventHandler),
true );
EventManager.RegisterClassHandler(
typeof(UIElement),
Keyboard.PreviewLostKeyboardFocusEvent,
new KeyboardFocusChangedEventHandler(OnKeyboardEventHandler),
true );
}
private static void OnKeyboardEventHandler(
object sender, KeyboardFocusChangedEventArgs e)
{
System.Diagnostics.Debug.WriteLine(
string.Format("Info : {0} : {1}", e.RoutedEvent, sender ) );
}
}