question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TabIndex not working in ItemsControl.DataTemplate by default

See original GitHub issue

I have an ItemsControl with n-TextBoxes which should be accessable by the Tab. Actually it is not working. I also tried to give each TextBox an own TabIndex (TabIndex="{Binding TabIndex}"; 1,2,…). Sadly as you can see in the preview it is not working.

<ItemsControl Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="5" Items="{Binding Path=LocalizedTexts}">
  <ItemsControl.ItemTemplate>
    <DataTemplate>
      <Grid>
        <Grid.ColumnDefinitions>
          <ColumnDefinition SharedSizeGroup="A" Width="Auto"/>
          <ColumnDefinition Width="20"/>
          <ColumnDefinition SharedSizeGroup="B" Width="Auto"/>
          <ColumnDefinition Width="20"/>
          <ColumnDefinition Width="*"/>
        </Grid.ColumnDefinitions>
        <TextBlock Grid.Column="0" Text="{Binding Locale}" VerticalAlignment="Center"/>
        <TextBlock Grid.Column="2" Text="{Binding OldText}" VerticalAlignment="Center"/>
        <TextBox Grid.Column="4" Text="{Binding Text, Mode=TwoWay}" IsTabStop="True" TabIndex="{Binding TabIndex}"/>
      </Grid>
    </DataTemplate>
  </ItemsControl.ItemTemplate>
</ItemsControl>

Tabindex

Avalonia v0.10.11 on Windows 10

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

7reactions
BAndysccommented, Jan 21, 2022

I think it is a feature, not a bug. You need to set KeyboardNavigation.TabNavigation property to Continue on ItemsPresenter.

<ItemsControl.Styles>
        <Style Selector="ItemsPresenter">
            <Setter Property="(KeyboardNavigation.TabNavigation)" Value="Continue" />
        </Style>
</ItemsControl.Styles>
1reaction
grokyscommented, Feb 15, 2022

Keeping this issue open for changing KeyboardNavigation.TabNavigation default value for list-like controls to match WPF defaults.

I think KeyboardNavigationMode.Once for ItemsControl is the same for WPF isn’t it? See https://stackoverflow.com/questions/1126838/tab-between-list-elements-wpf

Read more comments on GitHub >

github_iconTop Results From Across the Web

WPF TabStop / TabIndex in ItemsControl
It is not complete, but it is a starting point. ... ItemTemplate> </ItemsControl> <Button Content="Fix Tab indexes" Click="Button_Click" ...
Read more >
ItemsControl Class (System.Windows.Controls)
If an ItemsPanelTemplate is not specified, the default is used. (For ItemsControl, the default is an ItemsPanelTemplate that specifies a StackPanel.
Read more >
ItemsControl Class (System.Windows.Controls)
These elements become items in the Items collection. ... Gets or sets a value that modifies how tabbing and TabIndex work for this...
Read more >
Tabbing between items in a ListBox in WPF - Magnus Montin
Once by default. ListBoxItem. The ItemTemplate of the ListBox will be rendered inside a ListBoxItem container. In order to get rid of the...
Read more >
ItemsControl Class - Documentation | NoesisGUI
The default value 0 means "do not set AlternationIndex"; A positive value ... HasItems, Gets a value that indicates whether the ItemsControl contains...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found