Udostępnij za pośrednictwem


DesktopWindowXamlSource.GotFocus Event

Definition

Occurs when the DesktopWindowXamlSource gets focus in the desktop application (such as when the user presses the Tab key while focus is on the element just before the 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) 

Event Type

Remarks

When you add a DesktopWindowXamlSource to your desktop application, by default the DesktopWindowXamlSource does not automatically handle focus navigation via keyboard events such as the Tab or arrow keys. Call the NavigateFocus(Microsoft.UI.Xaml.Hosting.XamlSourceFocusNavigationRequest) method to programmatically give focus when the user navigates to the DesktopWindowXamlSource.

Handle GotFocus event to be notified when user enters the DesktopWindowXamlSource via some non-keyboard event, such as a mouse click, and you want to keep the state of the UI in the host desktop application up to date.

Applies to