tags:

views:

22

answers:

1

I have a listbox that has a datatemplate which contains multiple text boxes. I want the user to be able to tab through all of the textboxes and then to the textboxes of the next list item without having to use CTRL+TAB.

Some XAML:


<DataTemplate x:Key="UsersDataTemplate">
    <Grid>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="*"/>
            <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <Grid.RowDefinitions>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>
        <StackPanel  Orientation="Horizontal" Grid.Column="0" Grid.Row="0">
            <Label Content="Full Name" />
            <TextBox Text="{Binding Path=FullName}" />
        </StackPanel>
        <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="0">
            <Label Content="Address"  />
            <TextBox Text="{Binding Path=Address}" />
        </StackPanel>
        <StackPanel Orientation="Horizontal" Grid.Row="1" Grid.Column="1">
            <Label Content="City" />
            <TextBox Text="{Binding Path=City}" />
        </StackPanel>
        <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="0">
            <Label Content="State" />
            <TextBox Text="{Binding Path=State}" />
        </StackPanel>
        <StackPanel Orientation="Horizontal" Grid.Row="2" Grid.Column="1">
            <Label Content="Zip" />
            <TextBox Text="{Binding Path=Zip}" />
        </StackPanel>
    </Grid>
</DataTemplate>

<ListBox  ItemTemplate="{DynamicResource UsersDataTemplate}"
    ItemsSource="{Binding ElementName=MyUserControl, Path=Users}"
    Width="914"
    Margin="2,2,2,2" />

The idea is that the user may be presented with anywhere from 1 to 10 users in this listbox and they want to be able to tab into the listbox, editing/updating names & addresses and continue tabbing through all 10 users. The problem I am having is that when the user gets to the last textbox (zip) and hits tab, focus leaves the listbox completely.

I know this works with CTRL+TAB but this is unacceptable for the users experience. Is there a way to make the list box tab through its items with the TAB key instead of the CTRL+TAB key?

I tried using variations of KeyboardNavigation.TabNavigation, .ControlNavigation, etc without any luck, though I may be doing something wrong.

Any thoughts?

+1  A: 

Hello I tested adding the following code to listbox declaration

<ListBox  
KeyboardNavigation.TabNavigation="Continue"

works like a charm ;D

hkon