---
title: "Grouping with WPF GridDataControl"
published_at: "2009-07-09T05:35:00+00:00"
modified_at: "2025-04-23T11:48:57+00:00"
url: "https://www.syncfusion.com/blogs/post/grouping-with-wpf-griddatacontrol"
excerpt: "With the Vol. 3 release, the much awaited grouping and summaries support for the WPF grid will be out. This support works with the CollectionView grouping mode. The summaries are not a part of CollectionView grouping logic, so we included..."
taxonomy_category:
  - "WPF"
taxonomy_post_tag:
  - ".NET"
  - "Grid"
  - "Grouping"
  - "LINQ"
  - "WPF"
---

# Grouping with WPF GridDataControl

[wpf](https://www.syncfusion.com/blogs/author/wpf)

![Image](https://www.syncfusion.com/blogs/wp-content/uploads/2018/08/grouping_griddata_fddde4df.png)


With the Vol. 3 release, the much awaited grouping and summaries support for the WPF grid will be out. This support works with the CollectionView grouping mode. The summaries are not a part of CollectionView grouping logic, so we included high-level functions that will calculate the summaries of a group dynamically using LINQ methods. This only has the constraint of using IEnumerable<T> implemented data sources.

## **Interactive grouping**

![image](https://blog.syncfusion.com/wp-content/uploads/2018/10/interactive-grouping.png "image")

Considering you have the GridDataControl added in the XAML markup, just adding the following code snippet would let you define grouped columns.

```
<syncfusion:GridDataControl.GroupedColumns>
    <syncfusion:GridDataGroupColumn ColumnName="ShipCountry"/>
</syncfusion:GridDataControl.GroupedColumns>
```

## Defining Summaries

There are three different types of summaries present in GDC:

- Table Summary
- Group Summary
- Group Caption Summary

All of these have the same syntax to declare. You also have the option of seeing what kind of summary the end-user would prefer.

![image](https://blog.syncfusion.com/wp-content/uploads/2018/10/defining-summaries.png "image")

XAML code snippet:

**Table Summary**

<syncfusion:GridDataControl.TableSummaryRows>   
 <syncfusion:GridDataSummaryRow ShowSummaryInRow=”True” Title=”Total Freight: {FreightSummary} For {CountSummary} Items” TitleColumnCount=”2″>   
 <syncfusion:GridDataSummaryRow.SummaryColumns>   
 <syncfusion:GridDataSummaryColumn Name=”FreightSummary” MappingName=”Freight” SummaryType=”Int32Aggregate” Format=”‘{Sum:c}'” />   
 <syncfusion:GridDataSummaryColumn Name=”CountSummary” MappingName=”OrderDate” SummaryType=”CountAggregate” Format=”‘{Count:d}'” />   
 </syncfusion:GridDataSummaryRow.SummaryColumns>   
 </syncfusion:GridDataSummaryRow>   
</syncfusion:GridDataControl.TableSummaryRows>

**Group Summary**

<syncfusion:GridDataControl.SummaryRows>   
 <syncfusion:GridDataSummaryRow ShowSummaryInRow=”True” Title=”‘Charges – {FreightSummary} for {OrderCount} Items'”>   
 <syncfusion:GridDataSummaryRow.SummaryColumns>   
 <syncfusion:GridDataSummaryColumn Name=”FreightSummary” MappingName=”Freight” SummaryType=”Int32Aggregate” Format=”‘{Sum:c}'” />   
 <syncfusion:GridDataSummaryColumn Name=”OrderCount” MappingName=”OrderDate” SummaryType=”CountAggregate” Format=”‘{Count}'” />   
 </syncfusion:GridDataSummaryRow.SummaryColumns>   
 </syncfusion:GridDataSummaryRow>   
</syncfusion:GridDataControl.SummaryRows>

**Group Caption Summary**

<syncfusion:GridDataControl.CaptionSummaryRow>   
 <syncfusion:GridDataSummaryRow ShowSummaryInRow=”False” Title=”‘{Count} Items'” TitleColumnCount=”2″>   
 <syncfusion:GridDataSummaryRow.SummaryColumns>   
 <syncfusion:GridDataSummaryColumn Name=”FreightSummary” MappingName=”Freight” SummaryType=”Int32Aggregate” Format=”‘{Sum:##}'” >   
 </syncfusion:GridDataSummaryColumn>   
 </syncfusion:GridDataSummaryRow.SummaryColumns>   
 </syncfusion:GridDataSummaryRow>   
</syncfusion:GridDataControl.CaptionSummaryRow>

You may notice that each GridDataSummaryColumn has a Format property. This property specifies the value of the Summary and replaces it with a string that gets formatted. The below values are present for different summary types,

**CountAggregate**

- Count

**DoubleAggregate/Int32Aggregate**

- Count
- Max
- Min
- Sum
- Average

We can also add custom summaries and plug into the grid, but that needs a separate post to explain the workflow.
