KeyboardNavigation KeyboardNavigation KeyboardNavigation KeyboardNavigation Class

Definition

Provides logical and directional navigation between focusable objects.

public ref class KeyboardNavigation sealed
public sealed class KeyboardNavigation
type KeyboardNavigation = class
Public NotInheritable Class KeyboardNavigation
Inheritance
KeyboardNavigationKeyboardNavigationKeyboardNavigationKeyboardNavigation

Examples

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);
Dim navigationMenu As New Menu()
Dim item1 As New MenuItem()
Dim item2 As New MenuItem()
Dim item3 As New MenuItem()
Dim item4 As New MenuItem()

navigationMenu.Items.Add(item1)
navigationMenu.Items.Add(item2)
navigationMenu.Items.Add(item3)
navigationMenu.Items.Add(item4)

KeyboardNavigation.SetTabNavigation(navigationMenu, KeyboardNavigationMode.Cycle)

Remarks

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.

Fields

AcceptsReturnProperty AcceptsReturnProperty AcceptsReturnProperty AcceptsReturnProperty

Identifies the AcceptsReturn attached property.

ControlTabNavigationProperty ControlTabNavigationProperty ControlTabNavigationProperty ControlTabNavigationProperty

Identifies the ControlTabNavigation attached property.

DirectionalNavigationProperty DirectionalNavigationProperty DirectionalNavigationProperty DirectionalNavigationProperty

Identifies the DirectionalNavigation attached property.

IsTabStopProperty IsTabStopProperty IsTabStopProperty IsTabStopProperty

Identifies the IsTabStop attached property.

TabIndexProperty TabIndexProperty TabIndexProperty TabIndexProperty

Identifies the TabIndex attached property.

TabNavigationProperty TabNavigationProperty TabNavigationProperty TabNavigationProperty

Identifies the TabNavigation attached property.

Attached Properties

AcceptsReturn AcceptsReturn AcceptsReturn AcceptsReturn

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

ControlTabNavigation ControlTabNavigation ControlTabNavigation ControlTabNavigation

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

DirectionalNavigation DirectionalNavigation DirectionalNavigation DirectionalNavigation

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

IsTabStop IsTabStop IsTabStop IsTabStop

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

TabIndex TabIndex TabIndex TabIndex

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

TabNavigation TabNavigation TabNavigation TabNavigation

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

Methods

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetAcceptsReturn(DependencyObject) GetAcceptsReturn(DependencyObject) GetAcceptsReturn(DependencyObject) GetAcceptsReturn(DependencyObject)

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

GetControlTabNavigation(DependencyObject) GetControlTabNavigation(DependencyObject) GetControlTabNavigation(DependencyObject) GetControlTabNavigation(DependencyObject)

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

GetDirectionalNavigation(DependencyObject) GetDirectionalNavigation(DependencyObject) GetDirectionalNavigation(DependencyObject) GetDirectionalNavigation(DependencyObject)

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

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetIsTabStop(DependencyObject) GetIsTabStop(DependencyObject) GetIsTabStop(DependencyObject) GetIsTabStop(DependencyObject)

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

GetTabIndex(DependencyObject) GetTabIndex(DependencyObject) GetTabIndex(DependencyObject) GetTabIndex(DependencyObject)

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

GetTabNavigation(DependencyObject) GetTabNavigation(DependencyObject) GetTabNavigation(DependencyObject) GetTabNavigation(DependencyObject)

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

GetType() GetType() GetType() GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
SetAcceptsReturn(DependencyObject, Boolean) SetAcceptsReturn(DependencyObject, Boolean) SetAcceptsReturn(DependencyObject, Boolean) SetAcceptsReturn(DependencyObject, Boolean)

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

SetControlTabNavigation(DependencyObject, KeyboardNavigationMode) SetControlTabNavigation(DependencyObject, KeyboardNavigationMode) SetControlTabNavigation(DependencyObject, KeyboardNavigationMode) SetControlTabNavigation(DependencyObject, KeyboardNavigationMode)

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

SetDirectionalNavigation(DependencyObject, KeyboardNavigationMode) SetDirectionalNavigation(DependencyObject, KeyboardNavigationMode) SetDirectionalNavigation(DependencyObject, KeyboardNavigationMode) SetDirectionalNavigation(DependencyObject, KeyboardNavigationMode)

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

SetIsTabStop(DependencyObject, Boolean) SetIsTabStop(DependencyObject, Boolean) SetIsTabStop(DependencyObject, Boolean) SetIsTabStop(DependencyObject, Boolean)

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

SetTabIndex(DependencyObject, Int32) SetTabIndex(DependencyObject, Int32) SetTabIndex(DependencyObject, Int32) SetTabIndex(DependencyObject, Int32)

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

SetTabNavigation(DependencyObject, KeyboardNavigationMode) SetTabNavigation(DependencyObject, KeyboardNavigationMode) SetTabNavigation(DependencyObject, KeyboardNavigationMode) SetTabNavigation(DependencyObject, KeyboardNavigationMode)

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

ToString() ToString() ToString() ToString()

Returns a string that represents the current object.

(Inherited from Object)

Applies to

See also