FocusManager.LostFocus Event
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Occurs when an element within a container element (a focus scope) loses focus. This event is raised asynchronously, so focus might move again before bubbling is complete.
// Register
static event_token LostFocus(EventHandler<FocusManagerLostFocusEventArgs> const& handler) const;
// Revoke with event_token
static void LostFocus(event_token const* cookie) const;
// Revoke with event_revoker
static FocusManager::LostFocus_revoker LostFocus(auto_revoke_t, EventHandler<FocusManagerLostFocusEventArgs> const& handler) const;
public static event System.EventHandler<FocusManagerLostFocusEventArgs> LostFocus;
function onLostFocus(eventArgs) { /* Your code */ }
Windows.UI.Xaml.Input.FocusManager.addEventListener("lostfocus", onLostFocus);
Windows.UI.Xaml.Input.FocusManager.removeEventListener("lostfocus", onLostFocus);
- or -
Windows.UI.Xaml.Input.FocusManager.onlostfocus = onLostFocus;
Public Shared Custom Event LostFocus As EventHandler(Of FocusManagerLostFocusEventArgs)
Event Type
Windows requirements
Device family |
Windows 10, version 1809 (introduced in 10.0.17763.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v7.0)
|
Remarks
We recommend using the UIElement focus routed events instead of FocusManager events whenever possible.
UIElement focus events bubble up to the FocusManager in the following order:
- UIElement.LosingFocus/FocusManager.LosingFocus
- UIElement.GettingFocus/FocusManager.GettingFocus
- UIElement.LostFocus routed event is raised by the element that lost focus and the event bubbles up
- FocusManager.LostFocus is raised (even if the routed event is marked handled)
- UIElement.GotFocus routed event is raised by the element that received focus and the event bubbles up
- FocusManager.GotFocus is raised (even if the routed event is marked handled)