New to Telerik UI for WinUI? Download free 30-day trial

PropertyAggregateDescriptor

The PropertyAggregateDescriptor allows you to define a property and a function that are applied over the property values of the DataGrid, which accumulates an aggregated result based on the component data.

To set up the PropertyAggregateDescriptor, use the following properties:

  • PropertyName—Defines the name of the property that is used to compute the aggregate value.
  • Function—Defines a KnownFunction value that will be applied to the aggregate.
  • Caption—Defines the caption of the aggregate. You can use Caption to display text in the UI when the AggregatesTemplate is set.
  • Format—Defines the string format that will be applied over the aggregated value.

To display the aggregates, set the AggregatesTemplate property of the DataGrid column that will display the value. The data context in the template is a collection of AggregateResult objects. Each AggregateResult contains the Caption of the aggregate, the aggregated value, and the value with the applied Format.

The following example shows how to add a PropertyAggregateDescriptor to the DataGrid. It will take the values from the Value property of the row model and the result will be the Sum value. You can get the aggregate values by using the GetAggregateValue and GetAggregateValues methods of the IDataView interface.

<telerikGrid:RadDataGrid ItemsSource="{Binding Items}" AutoGenerateColumns="False"> 
    <telerikGrid:RadDataGrid.Columns> 
        <telerikGrid:DataGridTextColumn PropertyName="Value"> 
            <telerikGrid:DataGridTextColumn.AggregatesTemplate> 
                <DataTemplate> 
                    <StackPanel Orientation="Horizontal" VerticalAlignment="Center"> 
                        <TextBlock Text="{Binding [0].Caption}" /> 
                        <TextBlock Text="{Binding [0].FormattedValue}" Margin="5 0 0 0" /> 
                    </StackPanel> 
                </DataTemplate> 
            </telerikGrid:DataGridTextColumn.AggregatesTemplate> 
        </telerikGrid:DataGridTextColumn> 
    </telerikGrid:RadDataGrid.Columns> 
    <telerikGrid:RadDataGrid.AggregateDescriptors> 
        <telerikData:PropertyAggregateDescriptor PropertyName="Value" Function="Sum" Caption = "Total: " Format = "C" /> 
    </telerikGrid:RadDataGrid.AggregateDescriptors> 
</telerikGrid:RadDataGrid> 
The previous example uses the following namespaces:

xmlns:telerikGrid="using:Telerik.UI.Xaml.Controls.Grid" 
xmlns:telerikCore="using:Telerik.Data.Core" 
DataGrid with a Defined PropertyAggregateDescriptor

WinUI

In this article
Not finding the help you need?