UIElement.GettingFocus 事件

定義

發生在 UIElement 獲得焦點之前。 這個事件會同步提高,以確保活動在進行時焦點不會被轉移。

// Register
event_token GettingFocus(TypedEventHandler<UIElement, GettingFocusEventArgs const&> const& handler) const;

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

// Revoke with event_revoker
UIElement::GettingFocus_revoker GettingFocus(auto_revoke_t, TypedEventHandler<UIElement, GettingFocusEventArgs const&> const& handler) const;
public event TypedEventHandler<UIElement,GettingFocusEventArgs> GettingFocus;
function onGettingFocus(eventArgs) { /* Your code */ }
uIElement.addEventListener("gettingfocus", onGettingFocus);
uIElement.removeEventListener("gettingfocus", onGettingFocus);
- or -
uIElement.ongettingfocus = onGettingFocus;
Public Custom Event GettingFocus As TypedEventHandler(Of UIElement, GettingFocusEventArgs) 
<uiElement GettingFocus="eventhandler"/>

事件類型

備註

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

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

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

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

GettingFocus 是一個路由事件。 欲了解更多路由事件概念,請參閱 事件與路由事件總覽

適用於

另請參閱