共用方式為


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 */ }
Windows.UI.Xaml.Input.FocusManager.addEventListener("losingfocus", onLosingFocus);
Windows.UI.Xaml.Input.FocusManager.removeEventListener("losingfocus", onLosingFocus);
- or -
Windows.UI.Xaml.Input.FocusManager.onlosingfocus = onLosingFocus;
Public Shared Custom Event LosingFocus As EventHandler(Of LosingFocusEventArgs) 
<uiElement LosingFocus="eventhandler"/>

事件類型

Windows 需求

裝置系列
Windows 10, version 1809 (已於 10.0.17763.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v7.0 引進)

備註

建議您盡可能使用 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 (

適用於

另請參閱