FocusManager.TryMoveFocus FocusManager.TryMoveFocus FocusManager.TryMoveFocus FocusManager.TryMoveFocus Method

Definition

Overloads

TryMoveFocus(FocusNavigationDirection) TryMoveFocus(FocusNavigationDirection) TryMoveFocus(FocusNavigationDirection) TryMoveFocus(FocusNavigationDirection)

Attempts to change focus from the element with focus to the next focusable element in the specified direction.

TryMoveFocus(FocusNavigationDirection, FindNextElementOptions) TryMoveFocus(FocusNavigationDirection, FindNextElementOptions) TryMoveFocus(FocusNavigationDirection, FindNextElementOptions) 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) TryMoveFocus(FocusNavigationDirection) TryMoveFocus(FocusNavigationDirection) TryMoveFocus(FocusNavigationDirection)

Attempts to change focus from the element with focus to the next focusable element in the specified direction.

public : static Platform::Boolean TryMoveFocus(FocusNavigationDirection focusNavigationDirection)
static bool TryMoveFocus(FocusNavigationDirection focusNavigationDirection) const;
public static bool TryMoveFocus(FocusNavigationDirection focusNavigationDirection)
Public Shared Function TryMoveFocus(focusNavigationDirection As FocusNavigationDirection) As bool

Parameters

focusNavigationDirection
FocusNavigationDirection FocusNavigationDirection

The direction to traverse (in tab order).

Returns

bool bool

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).

See also

TryMoveFocus(FocusNavigationDirection, FindNextElementOptions) TryMoveFocus(FocusNavigationDirection, FindNextElementOptions) TryMoveFocus(FocusNavigationDirection, FindNextElementOptions) 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 Platform::Boolean TryMoveFocus(FocusNavigationDirection focusNavigationDirection, FindNextElementOptions focusNavigationOptions)
static bool TryMoveFocus(FocusNavigationDirection focusNavigationDirection, FindNextElementOptions focusNavigationOptions) const;
public static bool TryMoveFocus(FocusNavigationDirection focusNavigationDirection, FindNextElementOptions focusNavigationOptions)
Public Shared Function TryMoveFocus(focusNavigationDirection As FocusNavigationDirection, focusNavigationOptions As FindNextElementOptions) As bool

Parameters

focusNavigationDirection
FocusNavigationDirection FocusNavigationDirection

The direction to traverse (in tab order).

focusNavigationOptions
FindNextElementOptions FindNextElementOptions

The options to help identify the next element to receive focus with keyboard/controller/remote navigation.

Returns

bool bool

true if focus moved; otherwise, false.

Additional features and requirements

Device family
Windows 10 Creators Update (introduced v10.0.15063.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v4)

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