Xaml.LostFocus Xaml.LostFocus Xaml.LostFocus Xaml.LostFocus Event


Occurs when a UIElement loses focus.

public : event RoutedEventHandler LostFocus<>
// Register
event_token LostFocus(RoutedEventHandler<> const& handler) const;

// Revoke with event_token
void LostFocus(event_token const& cookie) const;

// Revoke with event_revoker
LostFocus_revoker LostFocus(auto_revoker_t, RoutedEventHandler<> const& handler) const;
public event RoutedEventHandler LostFocus<>
Public Event RoutedEventHandler LostFocus( Of )
<uiElement LostFocus="eventhandler"/>


Only one UI element can have focus.

A control can lose focus when another control gets focus, the application view changes, the user switches applications, or interacts with the system such that the application is no longer in the foreground.

Keyboard focus is particularly relevant for keyboard event handling, because only the currently keyboard-focused UIElement can be the source of the KeyUp and KeyDown key events. Applications might call Focus as an initialization action so that the key events in the app as a whole can be used to detect access or accelerator keys. For more info, see Keyboard interactions.

LostFocus is a routed event. For more info on the routed event concept, see Events and routed events overview.

Specific Windows Runtime controls may have class-based handling for the LostFocus event. If so, the control probably has an override for the method OnLostFocus. Typically the event is marked handled by the class handler, and the LostFocus event is not raised for handling by any user code handlers on that control. Controls might handle the event in order to unload a visual state that displayed a focus rectangle in response to OnGotFocus.

A control's focus rectangle is an important visual component that aids accessibility by identifying the current focused element and indicating where the user is within the tab sequence of the application UI. In some cases, the FocusState of the focus action is relevant for whether a visible focus indicator should display.

For more info on how class-based handling for events works, see Events and routed events overview. For more info on tab sequences and accessibility, see Keyboard accessibility.

See Also