Export (0) Print
Expand All
This topic has not yet been rated - Rate this topic

KeyboardNavigation Class

Provides logical and directional navigation between focusable objects.

System.Object
  System.Windows.Input.KeyboardNavigation

Namespace:  System.Windows.Input
Assembly:  PresentationFramework (in PresentationFramework.dll)
public sealed class KeyboardNavigation

The KeyboardNavigation type exposes the following members.

  NameDescription
Public attached propertyAcceptsReturnGets or sets a value indicating whether the Return character is accepted by a control.
Public attached propertyControlTabNavigationGets or sets the logical control tab navigation behavior for the children of the element that this property is set on.
Public attached propertyDirectionalNavigationGets or sets the directional navigation behavior for the children of the element that this property is set on.
Public attached propertyIsTabStopGets or sets a value indicating whether the element that this property is set on is a tab stop.
Public attached propertyTabIndexGets or sets the tab index for the element that this property is set on.
Public attached propertyTabNavigationGets or sets the logical tab navigation behavior for the children of the element that this property is set on.
Top
  NameDescription
Public methodEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodStatic memberGetAcceptsReturnGets the value of the AcceptsReturn attached property for the specified element.
Public methodStatic memberGetControlTabNavigationGets the value of the ControlTabNavigation attached property for the specified element.
Public methodStatic memberGetDirectionalNavigationGets the value of the DirectionalNavigation attached property for the specified element.
Public methodGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodStatic memberGetIsTabStopGets the value of the IsTabStop attached property for the specified element.
Public methodStatic memberGetTabIndexGets the value of the TabIndex  attached property for the specified element.
Public methodStatic memberGetTabNavigationGets the value of the TabNavigation attached property for the specified element.
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodStatic memberSetAcceptsReturnSets the value of the AcceptsReturn  attached property for the specified element.
Public methodStatic memberSetControlTabNavigationSets the value of the ControlTabNavigation attached property for the specified element.
Public methodStatic memberSetDirectionalNavigationSets the value of the DirectionalNavigation attached property for the specified element.
Public methodStatic memberSetIsTabStopSets the value of the IsTabStop attached property for the specified element.
Public methodStatic memberSetTabIndexSet the value of the TabIndex attached property for the specified element.
Public methodStatic memberSetTabNavigationSets the value of the TabNavigation attached property for the specified element.
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)
Top
  NameDescription
Public fieldStatic memberAcceptsReturnPropertyIdentifies the AcceptsReturn attached property.
Public fieldStatic memberControlTabNavigationPropertyIdentifies the ControlTabNavigation attached property.
Public fieldStatic memberDirectionalNavigationPropertyIdentifies the DirectionalNavigation attached property.
Public fieldStatic memberIsTabStopPropertyIdentifies the IsTabStop attached property.
Public fieldStatic memberTabIndexPropertyIdentifies the TabIndex attached property.
Public fieldStatic memberTabNavigationPropertyIdentifies the TabNavigation attached property.
Top

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

.NET Framework

Supported in: 4.5.1, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows Phone 8.1, Windows Phone 8, Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Did you find this helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2014 Microsoft. All rights reserved.