Control.FocusEngaged 事件

定義

當遊戲台/遠端互動 (控制項界限內限制焦點時發生) 。

// Register
event_token FocusEngaged(TypedEventHandler<Control, FocusEngagedEventArgs const&> const& handler) const;

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

// Revoke with event_revoker
Control::FocusEngaged_revoker FocusEngaged(auto_revoke_t, TypedEventHandler<Control, FocusEngagedEventArgs const&> const& handler) const;
public event TypedEventHandler<Control,FocusEngagedEventArgs> FocusEngaged;
function onFocusEngaged(eventArgs) { /* Your code */ }
control.addEventListener("focusengaged", onFocusEngaged);
control.removeEventListener("focusengaged", onFocusEngaged);
- or -
control.onfocusengaged = onFocusEngaged;
Public Custom Event FocusEngaged As TypedEventHandler(Of Control, FocusEngagedEventArgs) 
<control FocusEngaged="eventhandler"/>

事件類型

Windows 需求

裝置系列
Windows 10 Anniversary Edition (已於 10.0.14393.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v3.0 引進)

備註

如需事件資料,請參閱 FocusEngagedEventArgs

焦點參與可讓您更輕鬆地使用遊戲台或遙控器來與應用程式互動。 設定焦點參與不會影響鍵盤或其他輸入裝置。

IsFocusEngagementEnabled 屬性設定為 true時,它會將控制項標示為需要焦點參與。 這表示,使用者必須按下 \[A/選取\] 按鈕來「佔住」控制項並與它互動。 完成時,他們可以按 B/上一頁按鈕來解除控制項並離開控制項。

如需此屬性的詳細資訊,請參閱Xbox 和電視設計一文的焦點參與一節。

版本相容性

FocusEngaged 事件在 Windows 10 1607 版之前無法使用。 如果您的應用程式在 Microsoft Visual Studio 中的「最低平臺版本」設定小於此頁面稍後需求區塊中顯示的「引進版本」,您必須設計和測試您的應用程式以考慮此專案。 如需詳細資訊,請參閱 版本調適型程式碼

若要避免在舊版Windows 10上執行應用程式時發生例外狀況,請勿在沒有先執行執行時間檢查的情況下連線此事件。 此範例示範如何使用 ApiInformation 類別來檢查此事件是否存在,再使用它。

<Slider x:Name="slider1" Loaded="Slider_Loaded"/>
private void Slider_Loaded(object sender, RoutedEventArgs e)
{
    if (ApiInformation.IsEventPresent("Windows.UI.Xaml.Controls.Control", "FocusEngaged"))
    {
        slider1.FocusEngaged += Slider1_FocusEngaged;
    }
}

適用於