TabIndex, Focus()

Asked By Mel Something
08-Sep-10 05:13 AM
Earn up to 30 extra points for answering this tough question.
Hey,

I'm having an issue with TabIndex not tabbing the way it's supposed to. When I open a ChildWindow and the user selects criteria from there, the focus always goes back to the first field on the page.

I have StackPanel that contains a Grid. Then I have a bunch of TextBlocks and Texboxes which I've set TabIndexes on. The order of the Tabindex are correct etc etc etc.

My code:

<TextBlock HorizontalAlignment="Right" Grid.Row="3" Grid.Column="0" Margin="5" Text="One:" />

<TextBox Grid.Row="3" Grid.Column="1" Name="txtOne" TabIndex="0" Margin="1" Text="{Binding Whatever, Mode=TwoWay}" />

         

<TextBlock HorizontalAlignment="Right" Grid.Row="4" Grid.Column="0" Margin="5" Text="Two:" />

<TextBox Grid.Row="4" Grid.Column="1" Name="txtTwo" TabIndex="1" Margin="1" Text="{Binding Whatever, Mode=TwoWay}" KeyDown="txtTwo_KeyDown" />


In my xaml.cs I have an If statement checking if the apppropriate key was pressed to open a Search Grid that is popped via a ChildWindow. I then select parameters etc, and have a event that fires after a selection is made. Problem is every time I select and the ChildWindow closes, the focus returns to the txtOne, regardless of what TabIndex is next. Setting the control.Focus() in the xaml.cs doesn't work either.

This is driving me nuts! Any advice/suggestions would be awesome.
Create New Account