diff --git a/Perspex.Input/KeyboardDevice.cs b/Perspex.Input/KeyboardDevice.cs index 999db93ee5..e31172507d 100644 --- a/Perspex.Input/KeyboardDevice.cs +++ b/Perspex.Input/KeyboardDevice.cs @@ -48,26 +48,29 @@ namespace Perspex.Input public void SetFocusedElement(IInputElement element, bool keyboardNavigated) { - var interactive = this.FocusedElement as IInteractive; - - if (interactive != null) + if (element != this.FocusedElement) { - interactive.RaiseEvent(new RoutedEventArgs + var interactive = this.FocusedElement as IInteractive; + + if (interactive != null) { - RoutedEvent = InputElement.LostFocusEvent, - }); - } + interactive.RaiseEvent(new RoutedEventArgs + { + RoutedEvent = InputElement.LostFocusEvent, + }); + } - this.FocusedElement = element; - interactive = element as IInteractive; + this.FocusedElement = element; + interactive = element as IInteractive; - if (interactive != null) - { - interactive.RaiseEvent(new GotFocusEventArgs + if (interactive != null) { - RoutedEvent = InputElement.GotFocusEvent, - KeyboardNavigated = keyboardNavigated, - }); + interactive.RaiseEvent(new GotFocusEventArgs + { + RoutedEvent = InputElement.GotFocusEvent, + KeyboardNavigated = keyboardNavigated, + }); + } } }