KeyboardNavigation.TabNavigation Attached Property

 
System_CAPS_noteNote

The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

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

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

See GetTabNavigation, SetTabNavigation

Property Value

Type: System.Windows.Input.KeyboardNavigationMode

How the container will move the focus when tab navigation occurs. The default value is Continue.

Tab navigation is invoked by using the TAB key.

Identifier field

TabNavigationProperty

Metadata properties set to true

None

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);
Return to top
Show: