UIElement.LosingFocus 事件

定义

UIElement 失去焦点之前发生。 此事件是同步引发的,以确保在事件冒泡时不会移动焦点。

// Register
event_token LosingFocus(TypedEventHandler<UIElement, LosingFocusEventArgs const&> const& handler) const;

// Revoke with event_token
void LosingFocus(event_token const* cookie) const;

// Revoke with event_revoker
UIElement::LosingFocus_revoker LosingFocus(auto_revoke_t, TypedEventHandler<UIElement, LosingFocusEventArgs const&> const& handler) const;
public event TypedEventHandler<UIElement,LosingFocusEventArgs> LosingFocus;
function onLosingFocus(eventArgs) { /* Your code */ }
uIElement.addEventListener("losingfocus", onLosingFocus);
uIElement.removeEventListener("losingfocus", onLosingFocus);
- or -
uIElement.onlosingfocus = onLosingFocus;
Public Custom Event LosingFocus As TypedEventHandler(Of UIElement, LosingFocusEventArgs) 
<uiElement LosingFocus="eventhandler"/>

事件类型

Windows 要求

设备系列
Windows 10 Creators Update (在 10.0.15063.0 中引入)
API contract
Windows.Foundation.UniversalApiContract (在 v4.0 中引入)

注解

建议尽可能使用 UIElement 焦点路由事件而不是 FocusManager 事件。

一次只能有一个 UI 元素具有焦点。

当另一个控件获得焦点、应用程序视图更改、用户切换应用程序或用户与系统交互,使应用程序不再位于前台时,控件可能会失去焦点。

以编程方式在元素之间导航时, FocusNavigationDirection.PreviousFocusNavigationDirection.Next 不能与 FindNextElementOptions 一起使用。 只有 FocusNavigationDirection.UpFocusNavigationDirection.DownFocusNavigationDirection.LeftFocusNavigationDirection.Right 有效。

LosingFocus 是路由事件。 有关路由事件概念的详细信息,请参阅 事件和路由事件概述

适用于

另请参阅