Xceed DataGrid for WPF v7.2 Documentation
Providing a custom StatGroupHeaderControl

The following example demonstrates how to provide a custom StatGroupHeaderControl.

XAML
Copy Code
<Grid xmlns:xcdg="http://schemas.xceed.com/wpf/xaml/datagrid">
  <Grid.Resources>
      <xcdg:DataGridCollectionViewSource x:Key="cvs_orderdetails"
                                         Source="{Binding Source={x:Static Application.Current}, Path=OrderDetails}">
        <xcdg:DataGridCollectionViewSource.StatFunctions>
            <xcdg:CountFunction ResultPropertyName="orderid_count"
                                SourcePropertyName="OrderID"/>
            <xcdg:SumFunction ResultPropertyName="unitprice_sum"
                              SourcePropertyName="UnitPrice"/>
            <xcdg:AverageFunction ResultPropertyName="unitprice_average"
                                  SourcePropertyName="UnitPrice"/>
            <xcdg:SumFunction ResultPropertyName="quantity_sum"
                              SourcePropertyName="Quantity"/>
        </xcdg:DataGridCollectionViewSource.StatFunctions>
        <xcdg:DataGridCollectionViewSource.GroupDescriptions>
            <xcdg:DataGridGroupDescription PropertyName="ProductID"/>
        </xcdg:DataGridCollectionViewSource.GroupDescriptions>
      </xcdg:DataGridCollectionViewSource>
      <xcdg:StatResultConverter x:Key="valueConverter"/>
      <xcdg:GroupConfiguration x:Key="quantityGroupConfiguration"
                               DefaultHeadersFootersType="None">
        <xcdg:GroupConfiguration.Headers>
            <xcdg:GroupHeaderFooterItemTemplate VisibleWhenCollapsed="True">
              <DataTemplate>
                  <xcdg:StatGroupHeaderControl ShowGroupLabel="True"
                                               AutoCreateCells="False">
                    <xcdg:StatGroupHeaderControl.Cells>
                        <xcdg:StatCell FieldName="Quantity"
                                       ResultPropertyName="quantity_sum" />
                    </xcdg:StatGroupHeaderControl.Cells>
                  </xcdg:StatGroupHeaderControl>
              </DataTemplate>
            </xcdg:GroupHeaderFooterItemTemplate>
        </xcdg:GroupConfiguration.Headers>
      </xcdg:GroupConfiguration>
  </Grid.Resources>
  <xcdg:DataGridControl x:Name="OrderDetailsGrid"
                        ItemsSource="{Binding Source={StaticResource cvs_orderdetails}}">
      <xcdg:DataGridControl.Columns>
        <xcdg:Column FieldName="Quantity"
                     Title="Quantity"
                     GroupConfiguration="{StaticResource quantityGroupConfiguration}" />
      </xcdg:DataGridControl.Columns>
  </xcdg:DataGridControl>
</Grid>