Provides logical and directional navigation between focusable objects.
Namespace:
System.Windows.Input
Assembly:
PresentationFramework (in PresentationFramework.dll)
Visual Basic (Declaration)
Public NotInheritable Class KeyboardNavigation
Dim instance As KeyboardNavigation
public sealed class KeyboardNavigation
public ref class KeyboardNavigation sealed
public final class KeyboardNavigation
You cannot directly create an instance of this class in XAML.
The KeyboardNavigation class is responsible for implementing default keyboard focus navigation when one of the navigation keys is pressed. The navigation keys are: Tab, Shift+Tab, Ctrl+Tab, Ctrl+Shift+Tab, UpArrow, DownArrow, LeftArrow, and RightArrow keys.
An example of logical navigation is using the tab key to move focus.
An example of directional navigation is using the arrow keys to move focus.
The following example creates a Menu with a number of MenuItem objects. The TabNavigation attached property is set to Cycle on the Menu. This means that when focus is changed using the tab key within the Menu, focus will move from each element and when the last element is reached focus will return to the first element.
<Menu KeyboardNavigation.TabNavigation="Cycle">
<MenuItem Header="Menu Item 1" />
<MenuItem Header="Menu Item 2" />
<MenuItem Header="Menu Item 3" />
<MenuItem Header="Menu Item 4" />
</Menu>
Menu navigationMenu = new Menu();
MenuItem item1 = new MenuItem();
MenuItem item2 = new MenuItem();
MenuItem item3 = new MenuItem();
MenuItem item4 = new MenuItem();
navigationMenu.Items.Add(item1);
navigationMenu.Items.Add(item2);
navigationMenu.Items.Add(item3);
navigationMenu.Items.Add(item4);
KeyboardNavigation.SetTabNavigation(navigationMenu,
KeyboardNavigationMode.Cycle);
System..::.Object
System.Windows.Input..::.KeyboardNavigation
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Windows 7, Windows Vista, Windows XP SP2, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
.NET Framework
Supported in: 3.5, 3.0
Reference
Other Resources