New to Telerik UI for .NET MAUI? Start a free 30-day trial

Changing Sort Styling in DataGrid for MAUI

Environment

Version Product Author
11.0.0 Telerik UI for .NET MAUI DataGrid Dobrinka Yordanova

Description

I need to change the header styling in the DataGrid for MAUI when sorting is enabled. Specifically, I want the entire header to trigger sorting when clicked and customize the appearance of the sort arrows to match the design requirements.

This knowledge base article also answers the following questions:

  • How to style the header of DataGrid for MAUI with custom sort indicators?
  • How to change the appearance of the sort arrows in DataGrid for MAUI?
  • How to set custom text for the sort indicators in DataGrid for MAUI?

Solution

To customize the appearance of the sort indicator in the DataGrid for MAUI, use the SortIndicatorColor property to set the color of the sort indicator, and the SortIndicatorAscendingText and SortIndicatorDescendingText properties to define custom text or icons when sorting the data in ascending or descending order. These properties can be set directly within the HeaderStyle of the column.

The following sample code shows how to customize sort indicators in a Telerik .NET MAUI DataGrid by changing their color and using different icons when sorting up or down.

<telerik:RadDataGrid x:Name="dataGrid" AutoGenerateColumns="False">
    <telerik:RadDataGrid.Columns>
        <telerik:DataGridTextColumn PropertyName="Country">
            <telerik:DataGridTextColumn.HeaderStyle>
                <Style TargetType="telerik:DataGridColumnHeaderAppearance">
                    <Setter Property="SortIndicatorColor" Value="Blue" />
                    <Setter Property="SortIndicatorAscendingText" Value="{x:Static telerik:TelerikFont.IconAuthor}" />
                    <Setter Property="SortIndicatorDescendingText" Value="{x:Static telerik:TelerikFont.IconAlignCenter}" />
                </Style>
            </telerik:DataGridTextColumn.HeaderStyle>
        </telerik:DataGridTextColumn>
        <telerik:DataGridTextColumn PropertyName="Capital" />
    </telerik:RadDataGrid.Columns>
</telerik:RadDataGrid>

See Also

In this article