I have a view in WPF that I have been fighting to get the tab order correct on. I have three text boxes (lets call them Text1, Text2, and Text3) and two custom controls, each of which has several other text boxes and assorted controls on them (lets call them Custom1 and Custom2).
The layout is such that tab flow should go Text1, Text2, Custom1, Custom2, Text3. I have set the TabIndex property on each control to match this ordering, and verified that all of them are set to IsTabStop.
The problem is, the actual tab flow goes Text1, Text2, Text3, and then Custom1, Custom2, and I cannot figure out why. When it goes to the custom controls, it does properly step over every control in them as I would expect. I just can't figure out why it goes to the third text box before it goes to the first custom control.
I have tried everything I can think of, including making sure all of the xaml elements are arranged in tab order, but nothing seems to help.
I suspect it is going over all of its basic controls before giving focus to any custom controls, but I am out of ideas. Any help would be great.
EDIT: Here's my xaml:
<Grid>
<GroupBox x:Name="_groupBox" BorderBrush="Transparent" BorderThickness="0">
<Grid x:Name="_card">
<Label Content="A:" Height="28" HorizontalAlignment="Left" Margin="5,3,0,0" Name="_labelA" VerticalAlignment="Top" />
<Label Content="B:" Height="28" HorizontalAlignment="Left" Margin="5,25,0,0" Name="_labelB" VerticalAlignment="Top" />
<TextBox Name="_a" Height="20" HorizontalAlignment="Left" Text="{Binding AText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding AEnabled}" Margin="94,5,0,0" VerticalAlignment="Top" LostFocus="InputNameLeave" Width="221" TabIndex="0" />
<TextBox Name="_b" Height="20" HorizontalAlignment="Left" Margin="94,26,0,0" Text="{Binding BText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Top" Width="102" TabIndex="1" />
<my:CustomControlA HorizontalAlignment="Left" Margin="-6,55,0,0" x:Name="_custom1" VerticalAlignment="Top" TabIndex="2" IsTabStop="True" />
<my:CustomControlB HorizontalAlignment="Left" Margin="334,0,0,0" x:Name="_custom2" VerticalAlignment="Top" Width="320" TabIndex="3" IsTabStop="True" />
<Label Content="C:" Height="28" HorizontalAlignment="Left" Margin="342,59,0,0" Name="_labelC" VerticalAlignment="Top" />
<TextBox Name="_c" Height="20" HorizontalAlignment="Left" Margin="417,60,0,0" Text="{Binding CText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" IsEnabled="{Binding CEnabled}" VerticalAlignment="Top" Width="154" TabIndex="4" />
</Grid>
</GroupBox>
</Grid>