Windows.UI.Xaml.Input.FocusManager.TryMoveFocus
June 22, 2022 ยท View on GitHub
-description
Attempts to change focus from the element with focus to the next focusable element in the specified direction.
-parameters
-param focusNavigationDirection
The direction to traverse (in tab order).
-returns
true if focus moved; otherwise, false.
-remarks
The tab order is the order in which a user moves from one control to another by pressing the Tab key (forward) or Shift+Tab (backward).
This method uses tab order sequence and behavior to traverse all focusable elements in the UI.
If the focus is on the first element in the tab order and FocusNavigationDirection.Previous is specified, focus moves to the last element.
If the focus is on the last element in the tab order and FocusNavigationDirection.Next is specified, focus moves to the first element.
You can also use either the FindNextElement(FocusNavigationDirection, FindNextElementOptions) method or the FindNextElement(FocusNavigationDirection) method to programmatically move focus. These methods retrieve the element (as a DependencyObject) that will receive focus based on the specified navigation direction (directional navigation only, cannot be used to emulate tab navigation).
Note
We recommend using the FindNextElement method instead of FindNextFocusableElement because FindNextFocusableElement retrieves a UIElement, which returns null if the next focusable element is not a UIElement (such as a Hyperlink object).
-examples
-see-also
TryMoveFocus(FocusNavigationDirection focusNavigationDirection, FindNextElementOptions focusNavigationOptions), Keyboard interactions, Focus navigation for keyboard, gamepad, remote control, and accessibility tools, Programmatic focus navigation