Skip to content

Latest commit

 

History

History
36 lines (21 loc) · 1.99 KB

gettingfocuseventargs_trycancel_50138317.md

File metadata and controls

36 lines (21 loc) · 1.99 KB
-api-id -api-type
M:Microsoft.UI.Xaml.Input.GettingFocusEventArgs.TryCancel
winrt method

Microsoft.UI.Xaml.Input.GettingFocusEventArgs.TryCancel

-description

Attempts to cancel the ongoing focus action.

-returns

true if the focus action is canceled; otherwise, false.

-remarks

You should call the TryCancel method instead of setting this property.

The GotFocus routed event is raised on an element after it receives focus, while the LostFocus routed event is raised on an element after it loses focus.

The GettingFocus and LosingFocus routed events occur before the focus change takes place, which enables your application to modify or cancel the focus change behavior.

GettingFocus and LosingFocus are raised synchronously, while GotFocus and LostFocus are raised asynchronously. For example, if your app calls the Focus method of a control, GettingFocus is raised during the call, but GotFocus is raised after the call completes.

If focus is moved while these events are still bubbling, an exception is thrown.

-see-also

GettingFocusEventArgs.TrySetNewFocusedElement, Keyboard interactions, Focus navigation for keyboard, gamepad, remote control, and accessibility tools, Programmatic focus navigation

-examples