Skip to content

Latest commit

 

History

History
37 lines (23 loc) · 2.08 KB

gettingfocuseventargs_trysetnewfocusedelement_804964491.md

File metadata and controls

37 lines (23 loc) · 2.08 KB
-api-id -api-type
M:Windows.UI.Xaml.Input.GettingFocusEventArgs.TrySetNewFocusedElement(Windows.UI.Xaml.DependencyObject)
winrt method

Windows.UI.Xaml.Input.GettingFocusEventArgs.TrySetNewFocusedElement

-description

Attempts to redirect focus to the specified element instead of the original targeted element.

-parameters

-param element

The object on which to set focus.

-returns

True, if the focus action is redirected; otherwise, false.

-remarks

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.TryCancel, Keyboard interactions, Focus navigation for keyboard, gamepad, remote control, and accessibility tools, Programmatic focus navigation

-examples