#640 – Set the TabIndex Property to Change Tab Order

By default, the sequence of controls that get keyboard focus when the user clicks on the Tab key is based on their order in the logical tree.

If you want to change this Tab order, however, you can set the TabIndex property of each control.  The TabIndex value should start a 0 for the first control that should receive focus and then proceed sequentially, i.e. 1, 2, 3, etc.  Controls with a lower TabIndex will therefore get focus before controls with a higher TabIndex.

    <StackPanel Orientation="Vertical">
        <Button Content="Harpo" TabIndex="1" HorizontalAlignment="Center" Margin="5"/>
        <Button Content="Chico" TabIndex="0" HorizontalAlignment="Center" Margin="5"/>
        <Button Content="Groucho" TabIndex="2" HorizontalAlignment="Center" Margin="5"/>