我想要DataGrid
中包含分组
我的问题是如何做到这一点“平均值”,在组头?
下面是一个巨大的XAML
<DataGrid x:Name="dataGrid" Grid.Column="1" CanUserResizeRows="False" CanUserSortColumns="False" GridLinesVisibility="None" AutoGenerateColumns="False" ItemsSource="{Binding List}" HeadersVisibility="Column" Grid.IsSharedSizeScope="True">
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding A}" Header="A"/>
<DataGridTextColumn Binding="{Binding B}" Header="B"/>
<DataGridTextColumn Binding="{Binding C}" Header="C"/>
<DataGridTextColumn Binding="{Binding Group}" Header="Group"/>
</DataGrid.Columns>
<DataGrid.GroupStyle>
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="GroupItem">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="GroupItem">
<Border BorderBrush="Gray" BorderThickness="0.5" CornerRadius="4" Margin="3">
<Border.Background>
<LinearGradientBrush EndPoint="1,0.5" StartPoint="0,0.5">
<GradientStop Color="#FFACACAC" Offset="0"/>
<GradientStop Color="White" Offset="1"/>
</LinearGradientBrush>
</Border.Background>
<StackPanel>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition SharedSizeGroup="A"/>
<ColumnDefinition SharedSizeGroup="B"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<TextBlock Text="{Binding Name}" Margin="10,0,10,0"/>
<TextBlock Grid.Column="1" Text="{Binding ItemCount}" Margin="10,0,0,0"/>
<TextBlock Grid.Column="2" Text="test" Margin="10,0,0,0"/>
</Grid>
<Expander>
<Border BorderBrush="Gray" BorderThickness="0.5" Margin="3">
<ItemsPresenter/>
</Border>
</Expander>
</StackPanel>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</DataGrid.GroupStyle>
</DataGrid>
产生这种输出
我可以输出组名(绿色箭头)和计数器(红色箭头)。
如何为任一列输出平均值(让它成为A
),而不是“测试”?