我必须对数据报中的数据进行分组。
为此,我做了以下工作:
-
已将样式添加到资源:
> <Style x:Key="GroupHeaderStyle"
> TargetType="{x:Type GroupItem}">
> <Setter Property="Template">
> <Setter.Value>
> <ControlTemplate TargetType="{x:Type GroupItem}">
> <Expander IsExpanded="False"
> >
> <Expander.Header>
> <TextBlock Text="{Binding Name}"/>
> </Expander.Header>
> <ItemsPresenter />
> </Expander>
> </ControlTemplate>
> </Setter.Value>
> </Setter>
> </Style>
-
我将样式应用为:
<dg:DataGrid Grid.Row="1" Name="dgAuthor" HorizontalScrollBarVisibility="Hidden"
AutoGenerateColumns="False" RowHeaderWidth="17" RowHeight="25">
<dg:DataGrid.GroupStyle>
<GroupStyle ContainerStyle="{StaticResource GroupHeaderStyle}">
<GroupStyle.Panel>
<ItemsPanelTemplate>
<dg:DataGridRowsPresenter/>
</ItemsPanelTemplate>
</GroupStyle.Panel>
</GroupStyle>
</dg:DataGrid.GroupStyle>
</dg:DataGrid>
-
我将信息列表作为一个可观察的集合,并将其指定为项源,如下所示:
listcollectionview lcv=新建listcollectionview(infolist);
添加(new propertygroupdescription(“author”));
dgauthor.itemssource=lcv;
其中info是具有author、book、year属性的类。
我必须将DataGrid分组到author属性。
我可以显示解释程序,但看不到其中的任何行。
有人能告诉我密码有什么问题吗?