共用方式為


FocusManager.LosingFocus 事件

定義

發生于焦點從具有焦點的目前專案移至目標元素之前。 此事件會同步引發,以確保事件反升時不會移動焦點。

// 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"/>

事件類型

備註

建議您盡可能使用 UIElement 焦點路由事件,而不是 FocusManager 事件。

FocusNavigationDirection.PreviousFocusNavigationDirection.Next 無法與 FindNextElementOptions搭配使用。 僅支援 FocusNavigationDirection.UpFocusNavigationDirection.DownFocusNavigationDirection.LeftFocusNavigationDirection.Right

UIElement 焦點事件會以下列順序反升至 FocusManager:

  1. UIElement.LosingFocus/FocusManager.LosingFocus
  2. UIElement.GettingFocus/FocusManager.GettingFocus
  3. UIElement.LostFocus 路由事件是由遺失焦點的專案引發,而事件會反升
  4. 即使路由事件標示為已處理) ,仍會引發FocusManager.LostFocus (
  5. UIElement.GotFocus 路由事件是由接收焦點的專案引發,而事件會反升
  6. 即使路由事件標示為已處理) ,仍會引發FocusManager.GotFocus (

適用於

另請參閱