語言

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

事件類型

備註

我們建議盡可能使用 UIElement 的焦點路由事件,而非 FocusManager 事件。

一次只能對一個 UI 元素進行聚焦。

當另一個控制項被聚焦、應用程式視圖改變、使用者切換應用程式,或使用者與系統互動導致該應用程式不再處於前景時,控制項可能會失去焦點。

在程式化地在元素間切換時, FocusNavigationDirection.PriorFocusNavigationDirection.Next 無法與 FindNextElements Options 一起使用。 只有 FocusNavigationDirection.UpFocusNavigationDirection.DownFocusNavigationDirection.LeftFocusNavigationDirection.Right 是有效的。

LosingFocus 是一個被淘汰的事件。 欲了解更多路由事件概念,請參閱 事件與路由事件總覽

適用於

另請參閱