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 是路由事件。 如需路由事件概念的詳細資訊,請參閱 事件和路由事件概觀

適用於

另請參閱