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.PreviousFocusNavigationDirection.Next 無法與 FindNextElementOptions搭配使用。 只有 FocusNavigationDirection.UpFocusNavigationDirection.DownFocusNavigationDirection.LeftFocusNavigationDirection.Right 有效。

GettingFocus 是路由事件。 如需路由事件概念的詳細資訊,請參閱 事件和路由事件概觀

適用於

另請參閱