【发布时间】:2012-07-16 10:44:18
【问题描述】:
我已将分组添加到 ItemsControl:
<ItemsControl Style="{StaticResource SellingDashboardToDosList}" Grid.Row="2" BorderThickness="1" Background="#C7E8F8" HorizontalAlignment="Stretch" ItemsSource="{Binding ToDoList}" >
<ItemsControl.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="GroupItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GroupItem">
<GroupBox Header="{Binding Name}">
<ItemsPresenter />
</GroupBox>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</ItemsControl.GroupStyle>
</ItemsControl>
现在我只看到空的 GroupBox。我使用 Snoop 工具来探索应用程序,我发现 GroupBox ItemPresenters 是空的!可能是什么原因?
如果我从 ItemsControl(ItemsControl.GroupStyle 元素)中删除分组,那么一切正常,我会再次看到所有项目。我不需要对底层数据上下文进行任何更改即可查看所有项目。数据上下文(ItemsSource binging)的类型是 CollectionViewSource。
绑定跟踪已打开,但我没有看到任何绑定错误。
【问题讨论】:
-
样式适用于我的示例数据。看看分组字段数据。
-
我应该寻找什么?现在组的 ItemsPresenters 是空的。为什么?
-
你能上传一些你用一些数据尝试过的示例代码吗?
-
不能快速完成。我稍后会尝试这样做。
标签: wpf grouping itemscontrol