FocusManager.LosingFocus 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 before focus moves from the current element with focus to the target element. This event is raised synchronously to ensure focus isn't moved while the event is bubbling.
// Register
static event_token LosingFocus(EventHandler<LosingFocusEventArgs> const& handler) const;
// Revoke with event_token
static void LosingFocus(event_token const* cookie) const;
// Revoke with event_revoker
static FocusManager::LosingFocus_revoker LosingFocus(auto_revoke_t, EventHandler<LosingFocusEventArgs> const& handler) const;
public static event System.EventHandler<LosingFocusEventArgs> LosingFocus;
function onLosingFocus(eventArgs) { /* Your code */ }
Microsoft.UI.Xaml.Input.FocusManager.addEventListener("losingfocus", onLosingFocus);
Microsoft.UI.Xaml.Input.FocusManager.removeEventListener("losingfocus", onLosingFocus);
- or -
Microsoft.UI.Xaml.Input.FocusManager.onlosingfocus = onLosingFocus;
Public Shared Custom Event LosingFocus As EventHandler(Of LosingFocusEventArgs)
<uiElement LosingFocus="eventhandler"/>
Event Type
Remarks
We recommend using the UIElement focus routed events instead of FocusManager events whenever possible.
FocusNavigationDirection.Previous and FocusNavigationDirection.Next cannot be used with FindNextElementOptions. Only FocusNavigationDirection.Up, FocusNavigationDirection.Down, FocusNavigationDirection.Left, or FocusNavigationDirection.Right are supported.
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)