We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to apply different styles to the GridTableSummaryRow?

Platform: WPF |
Control: SfDataGrid |
.NET Framework: 4.5

The SfDataGrid provides option to display the TableSummary, either at the top or bottom of the SfDataGrid by setting the GridTableSummaryRow.Position property. It is possible to apply different styles for the top and bottom table summaries by using the StyleSelector and by setting the SfDataGrid.TableSummaryRowStyleSelector property. This is demonstrated in the following code example.

<!--Adds the code example in the Resources Define with Key-->.
<local:TableSummaryStyleSelector x:Key="tableSummaryStyleSelector" />
<Syncfusion:SfDataGrid x:Name="SfdataGrid"
                       TableSummaryRowStyleSelector="{StaticResource tableSummaryStyleSelector}"
                       ItemsSource="{Binding GDCSource}"
        <Syncfusion:GridTableSummaryRow Position="Top" ShowSummaryInRow="False">
                <Syncfusion:GridSummaryColumn Name="EmployeeSalary"
                                                  SummaryType="Int32Aggregate" />
        <Syncfusion:GridTableSummaryRow Position="Bottom" Title="Total EmployeeCount : {EmployeeCount}" ShowSummaryInRow="True">
                <Syncfusion:GridSummaryColumn Name="EmployeeCount"
                                  SummaryType="Int32Aggregate" />


Two different table summary styles are defined in the Application.Resources.

    <Style x:Key="TableSummaryStyle1" TargetType="Syncfusion:TableSummaryRowControl">
        <Setter Property="Foreground" Value="Red" />
    <Style x:Key="TableSummaryStyle2" TargetType="Syncfusion:TableSummaryRowControl">
        <Setter Property="Foreground" Value="Blue" />


Different styles are applied to the GridTableSummaryRow based on the GridTableSummaryRow.Position.

public class TableSummaryStyleSelector : StyleSelector
    public override Style SelectStyle(object item, DependencyObject container)
        var rowData = (item as SpannedDataRow).RowData;
        var summaryRecordEntry = rowData as SummaryRecordEntry;
        var gridTableSummaryRow = summaryRecordEntry.SummaryRow as GridTableSummaryRow;
        if (gridTableSummaryRow.Position == TableSummaryRowPosition.Top)
            return App.Current.Resources["TableSummaryStyle1"] as Style;
        else if (gridTableSummaryRow.Position == TableSummaryRowPosition.Bottom)
            return App.Current.Resources["TableSummaryStyle2"] as Style;
        return null;


In the following screenshot, the different styles are applied to the different GridTableSummaryRows.

Grid summary Row in Top and Botton



Sample Links:







2X faster development

The ultimate WPF UI toolkit to boost your development speed.
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile