C# datagrid中的分组-未显示行
我必须将数据分组到datagrid中。 为此,我做了以下工作:C# datagrid中的分组-未显示行,c#,wpf,datagrid,grouping,C#,Wpf,Datagrid,Grouping,我必须将数据分组到datagrid中。 为此,我做了以下工作: 已将样式添加到资源中,如下所示: >TargetType=“{x:Type-GroupItem}”> > > > > > > > >
>TargetType=“{x:Type-GroupItem}”>
>
>
>
> >
>
>
>
>
>
>
>
>
>
谁能告诉我代码有什么问题吗?设置
AutoGenerateColumns=“True”
明确地解决了这个问题。
我还添加了列定义
> <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>