Windows Dev Center

Collapse the table of content
Expand the table of content
Expand Minimize
Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

FocusManager class

A helper class that enables getting and setting the UI element that has focus.

Inheritance

Object
  FocusManager

Syntax


public sealed class FocusManager

Members

The FocusManager class has these types of members:

Methods

The FocusManager class has these methods. It also inherits methods from the Object class.

MethodDescription
GetFocusedElement Gets the element in the UI that has focus.
TryMoveFocus Attempts to change focus from the element with focus to the next focusable element in the specified direction.

 

Examples

Use TryMoveFocus to traverse between UI elements using the arrow keys.


private void Page_KeyUp(object sender, KeyRoutedEventArgs e)
{
   if (e.Key == Windows.System.VirtualKey.Up)
   {
      // Mimic Shift+Tab when user hits up arrow key.
      FocusManager.TryMoveFocus(FocusNavigationDirection.Previous);
   }
   else if (e.Key == Windows.System.VirtualKey.Down)
   {
      // Mimic Tab when user hits down arrow key.
      FocusManager.TryMoveFocus(FocusNavigationDirection.Next);
   }
}

Requirements (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.UI.Xaml.Input
Windows::UI::Xaml::Input [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Xaml.Input
Windows::UI::Xaml::Input [C++]

Metadata

Windows.winmd

Attributes

[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]
[WebHostHidden()]

 

 

Show:
© 2015 Microsoft