FocusManager.TryMoveFocus Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Overloads
TryMoveFocus(FocusNavigationDirection) |
Attempts to change focus from the element with focus to the next focusable element in the specified direction. |
TryMoveFocus(FocusNavigationDirection, FindNextElementOptions) |
Attempts to change focus from the element with focus to the next focusable element in the specified direction, using the specified navigation options. |
TryMoveFocus(FocusNavigationDirection)
Attempts to change focus from the element with focus to the next focusable element in the specified direction.
public:
static bool TryMoveFocus(FocusNavigationDirection focusNavigationDirection);
static bool TryMoveFocus(FocusNavigationDirection const& focusNavigationDirection);
/// [Windows.Foundation.Metadata.Overload("TryMoveFocus")]
static bool TryMoveFocus(FocusNavigationDirection const& focusNavigationDirection);
public static bool TryMoveFocus(FocusNavigationDirection focusNavigationDirection);
[Windows.Foundation.Metadata.Overload("TryMoveFocus")]
public static bool TryMoveFocus(FocusNavigationDirection focusNavigationDirection);
function tryMoveFocus(focusNavigationDirection)
Public Shared Function TryMoveFocus (focusNavigationDirection As FocusNavigationDirection) As Boolean
Parameters
- focusNavigationDirection
- FocusNavigationDirection
The direction to traverse (in tab order).
Returns
bool
true if focus moved; otherwise, false.
- Attributes
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).
See also
- TryMoveFocus(FocusNavigationDirection, FindNextElementOptions)
- Keyboard interactions
- Focus navigation for keyboard, gamepad, remote control, and accessibility tools
- Programmatic focus navigation
Applies to
TryMoveFocus(FocusNavigationDirection, FindNextElementOptions)
Attempts to change focus from the element with focus to the next focusable element in the specified direction, using the specified navigation options.
public:
static bool TryMoveFocus(FocusNavigationDirection focusNavigationDirection, FindNextElementOptions ^ focusNavigationOptions);
/// [Windows.Foundation.Metadata.Overload("TryMoveFocusWithOptions")]
static bool TryMoveFocus(FocusNavigationDirection const& focusNavigationDirection, FindNextElementOptions const& focusNavigationOptions);
[Windows.Foundation.Metadata.Overload("TryMoveFocusWithOptions")]
public static bool TryMoveFocus(FocusNavigationDirection focusNavigationDirection, FindNextElementOptions focusNavigationOptions);
function tryMoveFocus(focusNavigationDirection, focusNavigationOptions)
Public Shared Function TryMoveFocus (focusNavigationDirection As FocusNavigationDirection, focusNavigationOptions As FindNextElementOptions) As Boolean
Parameters
- focusNavigationDirection
- FocusNavigationDirection
The direction to traverse (in tab order).
- focusNavigationOptions
- FindNextElementOptions
The options to help identify the next element to receive focus with keyboard/controller/remote navigation.
Returns
bool
true if focus moved; otherwise, false.
- Attributes
Windows requirements
Device family |
Windows 10 Creators Update (introduced in 10.0.15063.0)
|
API contract |
Windows.Foundation.UniversalApiContract (introduced in v4.0)
|
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).
See also
- TryMoveFocus(FocusNavigationDirection)
- Keyboard interactions
- Focus navigation for keyboard, gamepad, remote control, and accessibility tools
- Programmatic focus navigation