KeyboardNavigation Class

 

Provides logical and directional navigation between focusable objects.

Namespace:   System.Windows.Input
Assembly:  PresentationFramework (in PresentationFramework.dll)

System.Object
  System.Windows.Input.KeyboardNavigation

public sealed class KeyboardNavigation

NameDescription
System_CAPS_pubpropertySystem_CAPS_staticAcceptsReturn

Gets or sets a value indicating whether the Return character is accepted by a control.

System_CAPS_pubpropertySystem_CAPS_staticControlTabNavigation

Gets or sets the logical control tab navigation behavior for the children of the element that this property is set on.

System_CAPS_pubpropertySystem_CAPS_staticDirectionalNavigation

Gets or sets the directional navigation behavior for the children of the element that this property is set on.

System_CAPS_pubpropertySystem_CAPS_staticIsTabStop

Gets or sets a value indicating whether the element that this property is set on is a tab stop.

System_CAPS_pubpropertySystem_CAPS_staticTabIndex

Gets or sets the tab index for the element that this property is set on.

System_CAPS_pubpropertySystem_CAPS_staticTabNavigation

Gets or sets the logical tab navigation behavior for the children of the element that this property is set on.

NameDescription
System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticGetAcceptsReturn(DependencyObject)

Gets the value of the AcceptsReturn attached property for the specified element.

System_CAPS_pubmethodSystem_CAPS_staticGetControlTabNavigation(DependencyObject)

Gets the value of the ControlTabNavigation attached property for the specified element.

System_CAPS_pubmethodSystem_CAPS_staticGetDirectionalNavigation(DependencyObject)

Gets the value of the DirectionalNavigation attached property for the specified element.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticGetIsTabStop(DependencyObject)

Gets the value of the IsTabStop attached property for the specified element.

System_CAPS_pubmethodSystem_CAPS_staticGetTabIndex(DependencyObject)

Gets the value of the TabIndex  attached property for the specified element.

System_CAPS_pubmethodSystem_CAPS_staticGetTabNavigation(DependencyObject)

Gets the value of the TabNavigation attached property for the specified element.

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_pubmethodSystem_CAPS_staticSetAcceptsReturn(DependencyObject, Boolean)

Sets the value of the AcceptsReturn  attached property for the specified element.

System_CAPS_pubmethodSystem_CAPS_staticSetControlTabNavigation(DependencyObject, KeyboardNavigationMode)

Sets the value of the ControlTabNavigation attached property for the specified element.

System_CAPS_pubmethodSystem_CAPS_staticSetDirectionalNavigation(DependencyObject, KeyboardNavigationMode)

Sets the value of the DirectionalNavigation attached property for the specified element.

System_CAPS_pubmethodSystem_CAPS_staticSetIsTabStop(DependencyObject, Boolean)

Sets the value of the IsTabStop attached property for the specified element.

System_CAPS_pubmethodSystem_CAPS_staticSetTabIndex(DependencyObject, Int32)

Set the value of the TabIndex attached property for the specified element.

System_CAPS_pubmethodSystem_CAPS_staticSetTabNavigation(DependencyObject, KeyboardNavigationMode)

Sets the value of the TabNavigation attached property for the specified element.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

NameDescription
System_CAPS_pubfieldSystem_CAPS_staticAcceptsReturnProperty

Identifies the AcceptsReturn attached property.

System_CAPS_pubfieldSystem_CAPS_staticControlTabNavigationProperty

Identifies the ControlTabNavigation attached property.

System_CAPS_pubfieldSystem_CAPS_staticDirectionalNavigationProperty

Identifies the DirectionalNavigation attached property.

System_CAPS_pubfieldSystem_CAPS_staticIsTabStopProperty

Identifies the IsTabStop attached property.

System_CAPS_pubfieldSystem_CAPS_staticTabIndexProperty

Identifies the TabIndex attached property.

System_CAPS_pubfieldSystem_CAPS_staticTabNavigationProperty

Identifies the TabNavigation attached property.

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
Available since 3.0

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Return to top
Show: