KeyboardNavigation Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
-
KeyboardNavigation
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 |
Identifies the AcceptsReturn attached property. |
ControlTabNavigationProperty |
Identifies the ControlTabNavigation attached property. |
DirectionalNavigationProperty |
Identifies the DirectionalNavigation attached property. |
IsTabStopProperty |
Identifies the IsTabStop attached property. |
TabIndexProperty |
Identifies the TabIndex attached property. |
TabNavigationProperty |
Identifies the TabNavigation attached property. |
Attached Properties
AcceptsReturn |
Gets or sets a value indicating whether the Return character is accepted by a control. |
ControlTabNavigation |
Gets or sets the logical control tab navigation behavior for the children of the element that this property is set on. |
DirectionalNavigation |
Gets or sets the directional navigation behavior for the children of the element that this property is set on. |
IsTabStop |
Gets or sets a value indicating whether the element that this property is set on is a tab stop. |
TabIndex |
Gets or sets the tab index for the element that this property is set on. |
TabNavigation |
Gets or sets the logical tab navigation behavior for the children of the element that this property is set on. |
Methods
Equals(Object) |
Determines whether the specified object is equal to the current object. (Inherited from Object) |
GetAcceptsReturn(DependencyObject) |
Gets the value of the AcceptsReturn attached property for the specified element. |
GetControlTabNavigation(DependencyObject) |
Gets the value of the ControlTabNavigation attached property for the specified element. |
GetDirectionalNavigation(DependencyObject) |
Gets the value of the DirectionalNavigation attached property for the specified element. |
GetHashCode() |
Serves as the default hash function. (Inherited from Object) |
GetIsTabStop(DependencyObject) |
Gets the value of the IsTabStop attached property for the specified element. |
GetTabIndex(DependencyObject) |
Gets the value of the TabIndex attached property for the specified element. |
GetTabNavigation(DependencyObject) |
Gets the value of the TabNavigation attached property for the specified element. |
GetType() |
Gets the Type of the current instance. (Inherited from Object) |
MemberwiseClone() |
Creates a shallow copy of the current Object. (Inherited from Object) |
SetAcceptsReturn(DependencyObject, Boolean) |
Sets the value of the AcceptsReturn attached property for the specified element. |
SetControlTabNavigation(DependencyObject, KeyboardNavigationMode) |
Sets the value of the ControlTabNavigation attached property for the specified element. |
SetDirectionalNavigation(DependencyObject, KeyboardNavigationMode) |
Sets the value of the DirectionalNavigation attached property for the specified element. |
SetIsTabStop(DependencyObject, Boolean) |
Sets the value of the IsTabStop attached property for the specified element. |
SetTabIndex(DependencyObject, Int32) |
Set the value of the TabIndex attached property for the specified element. |
SetTabNavigation(DependencyObject, KeyboardNavigationMode) |
Sets the value of the TabNavigation attached property for the specified element. |
ToString() |
Returns a string that represents the current object. (Inherited from Object) |