Setting tab order in WPF

How to set tab order in WPF? I have an ItemControl with some details expanded, and some have fallen off and would like to skip minimized when I'm tabbing.

Any ideas?

+78
wpf tab-ordering
Dec 11 '08 at 15:40
source share
6 answers

You can skip items in a sequence of tabs by setting KeyboardNavigation.IsTabStop to an item in XAML.

KeyboardNavigation.IsTabStop="False" 

You can configure a trigger that will switch this property based on the advanced state.

+55
Dec 11 '08 at 19:34
source share

If you want to explicitly customize the tab order for elements in your form, it is assumed that the following property is attached:

 <Control KeyboardNavigation.TabIndex="0" ... /> 

I say โ€œshould helpโ€ because I did not find it very reliable, although I probably need to learn more about how it is intended for use. I am only posting this half-baked answer because no one has mentioned this property.




Note that in Win RT, the property is simply TabIndex="0" .

+75
Feb 26 '09 at 17:52
source share

<Control KeyboardNavigation.TabIndex="0" ... /> Works fine ... For example -

 <ComboBox Height="23" Margin="148,24,78,0" Name="comboBoxDataSet" VerticalAlignment="Top" SelectionChanged="comboBoxDestMarketDataSet_SelectionChanged" DropDownOpened="comboBoxDestMarketDataSet_DropDownOpened" KeyboardNavigation.TabIndex="0" /> <ComboBox Height="23" Margin="148,56,78,0" Name="comboBoxCategory" VerticalAlignment="Top" SelectionChanged="comboBoxDestCategory_SelectionChanged" DropDownOpened="comboBoxDestCategory_DropDownOpened" KeyboardNavigation.TabIndex="1" /> 

Allows you to navigate through these two fields using the TAB key.

+22
May 25 '10 at 3:16 a.m.
source share

I think there is a much easier solution here, at the top of your control or window or something else, you can add:

 KeyboardNavigation.TabNavigation="Cycle" 

It also automatically ignores folded tabs.

+8
Nov 30 '11 at 13:50
source share

Another alternative that has worked for me in the past is to simply remove all explicit TabIndex expressions, and let the controls use the order they declared in XAML to work with their magic.

This, of course, may require you to reorder your controls. But this is a simple copy-paste operation.

+4
Jun 06 '14 at 16:59
source share

Also, .NET 3.0 has a class that automatically sets the order of tabs, and you can override this based on sections of your form.

  (new TabOrderManager(this)).SetTabOrder(TabOrderManager.TabScheme.AcrossFirst); 
-9
Dec 11 '08 at 19:40
source share



All Articles