FocusManager.GotFocus イベント

定義

コンテナー要素 (フォーカス スコープ) 内の要素がフォーカスを受け取ったときに発生します。 このイベントは非同期的に発生するため、バブルが完了する前にフォーカスが移動する可能性があります。

// Register
static event_token GotFocus(EventHandler<FocusManagerGotFocusEventArgs> const& handler) const;

// Revoke with event_token
static void GotFocus(event_token const* cookie) const;

// Revoke with event_revoker
static FocusManager::GotFocus_revoker GotFocus(auto_revoke_t, EventHandler<FocusManagerGotFocusEventArgs> const& handler) const;
public static event System.EventHandler<FocusManagerGotFocusEventArgs> GotFocus;
function onGotFocus(eventArgs) { /* Your code */ }
Microsoft.UI.Xaml.Input.FocusManager.addEventListener("gotfocus", onGotFocus);
Microsoft.UI.Xaml.Input.FocusManager.removeEventListener("gotfocus", onGotFocus);
- or -
Microsoft.UI.Xaml.Input.FocusManager.ongotfocus = onGotFocus;
Public Shared Custom Event GotFocus As EventHandler(Of FocusManagerGotFocusEventArgs) 

イベントの種類

注釈

可能な限り、FocusManager イベントではなく UIElement フォーカス ルーティング イベントを使用することをお勧めします。

UIElement フォーカス イベントは、次の順序で FocusManager にバブル アップします。

  1. UIElement.LosingFocus/FocusManager.LosingFocus
  2. UIElement.GettingFocus/FocusManager.GettingFocus
  3. UIElement.LostFocus ルーティング イベントは、フォーカスを失い、イベントがバブルアップした要素によって発生します
  4. FocusManager.LostFocus が発生します (ルーティング イベントが処理済みとマークされている場合でも)
  5. UIElement.GotFocus ルーティング イベントは、フォーカスを受け取った要素によって発生し、イベントがバブルアップします
  6. FocusManager.GotFocus が発生します (ルーティング イベントが処理済みとマークされている場合でも)

適用対象

こちらもご覧ください