Search code examples
wpfitemscontroltabstop

WPF Disabling TabStop for ObjectDataProvider


I have a ObjectDataProvider of check boxes:

<UserControl.Resources>
        <ObjectDataProvider x:Key="checkboxes" ObjectType="{x:Type Models:Items}" />
        <DataTemplate x:Key="Item" DataType="Models:Item" >
            <CheckBox Content="{Binding Path=Name}" IsChecked="{Binding Path=Include}" />
        </DataTemplate>
        <ItemsPanelTemplate x:Key="HorizontalList" >
            <StackPanel Orientation="Horizontal" />
        </ItemsPanelTemplate>
    </UserControl.Resources>

When I tab through the controls and get to the datatemplate, it looks selects the it before going to the controls inside, like this -

tabstop selecting objectdataprovider

Is there any way to turn this off?

Conclusion

It isn't the ObjectDataProvider, but rather the ItemsControl that needs to be turned off -

<ItemsControl ItemsSource="{Binding ElementName=container,Path=ViewModel.Items}"
                          ItemTemplate="{StaticResource Item}"
                          ItemsPanel="{StaticResource HorizontalList}"
                          IsTabStop="False"/>

Thanks!


Solution

  • There is no problem with ObjectDataProvider in your code, just try to set IsTabStop = false in the container where CheckBoxes are. can you provide more xaml code from UserControl?