Share via


DesktopWindowXamlSource.GotFocus 事件

定义

DesktopWindowXamlSource 在桌面应用程序 (获得焦点时发生,例如当用户按下 Tab 键时,焦点位于 DesktopWindowXamlSource) 之前的 元素上。

// Register
event_token GotFocus(TypedEventHandler<DesktopWindowXamlSource, DesktopWindowXamlSourceGotFocusEventArgs const&> const& handler) const;

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

// Revoke with event_revoker
DesktopWindowXamlSource::GotFocus_revoker GotFocus(auto_revoke_t, TypedEventHandler<DesktopWindowXamlSource, DesktopWindowXamlSourceGotFocusEventArgs const&> const& handler) const;
public event TypedEventHandler<DesktopWindowXamlSource,DesktopWindowXamlSourceGotFocusEventArgs> GotFocus;
function onGotFocus(eventArgs) { /* Your code */ }
desktopWindowXamlSource.addEventListener("gotfocus", onGotFocus);
desktopWindowXamlSource.removeEventListener("gotfocus", onGotFocus);
- or -
desktopWindowXamlSource.ongotfocus = onGotFocus;
Public Custom Event GotFocus As TypedEventHandler(Of DesktopWindowXamlSource, DesktopWindowXamlSourceGotFocusEventArgs) 

事件类型

注解

DesktopWindowXamlSource 添加到桌面应用程序时,默认情况下 ,DesktopWindowXamlSource 不会通过键盘事件(如 Tab 键或箭头键)自动处理焦点导航。 调用 NavigateFocus (Microsoft.UI.Xaml.Hosting.XamlSourceFocusNavigationRequest) 方法,以编程方式在用户导航到 DesktopWindowXamlSource 时提供焦点。

处理 GotFocus 事件,当用户通过某些非键盘事件(例如鼠标单击)进入 DesktopWindowXamlSource 时收到通知,并且你希望主机桌面应用程序中的 UI 状态保持最新。

适用于