Question

I am working on a List View and I would like to tab through the collection in the list view.

Now the part that makes it a bit harder is that I want to tab through the two text boxes in item's template and then move to the next item in the List View.

Xaml:

<ListView ItemsSource="{Binding Parameters}" HorizontalAlignment="Stretch" 
          HorizontalContentAlignment="Stretch" AlternationCount="2"
          ItemContainerStyle="{DynamicResource CustomListViewItemStyle}" 
          IsTabStop="False">

          <ListView.ItemTemplate>
                   <DataTemplate>
                        <WrapPanel>
                            <TextBox Text="Text Box 1" />
                            <TextBox Text="Text Box 2" />
                            <CheckBox Content="Present"/>
                        </WrapPanel>
                   </DataTemplate>
          </ListView.ItemTemplate>

          <ListView.Resources>
              <Style x:Key="CustomListViewItemStyle" TargetType="{x:Type ListViewItem}">
                   <Style.Triggers>
                         <Trigger Property="ItemsControl.AlternationIndex" Value="0">
                             <Setter Property="Background" Value="White"></Setter>
                         </Trigger>
                         <Trigger Property="ItemsControl.AlternationIndex" Value="1">
                             <Setter Property="Background" Value="Gainsboro"></Setter>                                    
                         </Trigger>
                   </Style.Triggers>
                   <Setter Property="IsSelected" Value="{Binding ParamSelected}" />
              </Style>
          </ListView.Resources>
</ListView>

Expected tab is: "Text Box 1" > "Text Box 2" > Next Item in List View - "Text Box 1" etc...

Any help is greatly appreciated.

Was it helpful?

Solution

Found out I can use KeyboardNavigation.TabNavigation="Cycle" within the List View.

Also set the check box as below

<CheckBox Content="Present" IsTabStop="False"/>.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top