WPF 禁用 ObjectDataProvider 的 TabStop
我有一个带有复选框的 ObjectDataProvider:
<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>
当我通过选项卡浏览控件并进入数据模板时,它看起来会在进入内部控件之前选择它,如下所示 -
有什么方法可以关闭此功能吗?
结论
需要关闭的不是 ObjectDataProvider,而是 ItemsControl -
<ItemsControl ItemsSource="{Binding ElementName=container,Path=ViewModel.Items}"
ItemTemplate="{StaticResource Item}"
ItemsPanel="{StaticResource HorizontalList}"
IsTabStop="False"/>
谢谢!
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 -
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你代码中的ObjectDataProvider没有问题,只要尝试在CheckBox所在的容器中设置
IsTabStop = false
即可。你能提供更多来自 UserControl 的 xaml 代码吗?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?