1
votes

In wpf Textbox has TabIndex property to set the tab order, this is working fine when the controls are in the same context, In my case i have a listbox whose itemstyle has a text box and the style is assigned dynamically based on trigger. now how can i do the tabindexing so that when i tab index moves from textbox in first listboxitem to the textbox or combobox or button in the next listboxitem and as to the further listboxitems.

Thanks

Arvind

1
Specify which language you are using?Sauron
I am using .net 3.5 wpf with C#Arvind

1 Answers

2
votes

You need to specify the TabNavigation attached property so that WPF knows what to do when the user presses tab and there are no more controls in the current scope to tab to:

<ListBox>
    <ListBox.ItemContainerStyle>
        <Style TargetType="ListBoxItem">
            <Setter Property="KeyboardNavigation.TabNavigation" Value="Continue"/>
        </Style>
    </ListBox.ItemContainerStyle>
</ListBox>

Above I specify that when there are no more items in the ListBoxItem on which to focus, pressing tab should continue to the next logical focus container (ie. the next ListBoxItem).