DockPanel Tab Order
If you want to retain the DockPanel, you can use KeyboardNavigation.TabNavigation="Local" on the parent dockpanel, and then you CAN set the tab index values on the controls within it.
Like this -
<ItemsControl HorizontalContentAlignment="Stretch"> <ItemsControl.ItemTemplate> <DataTemplate> <DockPanel KeyboardNavigation.TabNavigation="Local"> <ComboBox DockPanel.Dock="Left" TabIndex="1"/> <ComboBox DockPanel.Dock="Left" TabIndex="2"/> <Button DockPanel.Dock="Right" TabIndex="4">Button</Button> <!-- This will appear before the button...it has to go after it in the XAML so it will fill properly in the DockPanel --> <TextBox DockPanel.Dock="Left" MinWidth="100" HorizontalAlignment="Stretch" TabIndex="3"/> </DockPanel> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl>
As you found, if you just set the tab index values of the controls, these are global to the form, so all the TabIndex="0" are tabbed into first, then all the TabIndex="1", and so on. Set KeyboardNavigation.TabNavigation="Local" on the parent container fixes it.
You could use a Grid instead of the DockPanel, like so:
<Grid> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="*"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <ComboBox /> <ComboBox Grid.Column="1"/> <TextBox Grid.Column="2" MinWidth="100" /> <Button Grid.Column="3">Button</Button> </Grid>
And if you want them to align nicely in the different columns - you could use SharedSizeGroup.
Have you tried explicitly setting the tab order?
<Control KeyboardNavigation.TabIndex="0" />