看起来当两者都被指定时,
唯一的区别是
编辑后链接到http://wpftutorial.net/DataGrid.html#grouping。我实际上没有直接从那里拿到示例,但那是一个非常好的网站,因此它们可以获得链接。
ContainerStyle
优先于 HeaderTemplate
被使用,如下所示;<controls:DataGrid.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding Path=Name}" Background="Yellow" />
</StackPanel>
</DataTemplate>
</GroupStyle.HeaderTemplate>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="true" Background="Violet">
<Expander.Header>
<DockPanel TextBlock.FontWeight="Bold">
<TextBlock Text="{Binding Path=Name}" />
<TextBlock Text="{Binding Path=ItemCount}"/>
</DockPanel>
</Expander.Header>
<ItemsPresenter />
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</controls:DataGrid.GroupStyle>
唯一的区别是
HeaderTemplate
无法访问ItemsPresenter
,还是与分层数据结构有关?谢谢!编辑后链接到http://wpftutorial.net/DataGrid.html#grouping。我实际上没有直接从那里拿到示例,但那是一个非常好的网站,因此它们可以获得链接。