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

Columns Styling

The DataGrid component provides styling mechanism for customizing the look of the columns and their cells.

The styling mechanism is represented by the following properties:

  • HeaderStyle (DataGridColumnHeaderStyle)
  • CellContentStyle (Style with TargetType depending on the column type)
  • CellDecorationStyle (DataGridBorderStyle)
  • CellEditorStyle (Style with TargetType depending on the editor type)
  • FooterStyle (DataGridColumnFooterStyle)

HeaderStyle

HeaderStyle defines the appearance of the column header. The DataGridColumnHeaderStyle exposes properties for styling its header, filter indicator, indicator, Options button, and sorting indicator.

Header Styling

To style the RadDataGridColumnHeader use the following properties:

  • TextColor and BackgroundColor—Define the colors of the text part/background respectively.
  • BorderColor and BorderThickness—Define the style of the border around the column header.
  • Font Options (TextFontAttributes, TextFontFamily, TextFontSize)—Define the font options to the text part of the ColumnHeader.
  • Text Alignment (TextMargin, HorizontalTextAlignment, VerticalTextAlignment)—Define the positioning for the text part of the ColumnHeader.
<telerik:DataGridTextColumn.HeaderStyle>
    <telerik:DataGridColumnHeaderStyle BackgroundColor="LightSkyBlue"
                                       TextColor="Black"
                                       BorderColor="Black"
                                       BorderThickness="2"/>
</telerik:DataGridTextColumn.HeaderStyle>

SortIndicator Styling

The SortIndicator is shown once the RadDataGridColumnHeader is sorted (tapped/clicked on the ColumnHeader cell) and can be styled with the following properties:

  • SortIndicatorColor—Defines the color for the sort indicator part of the ColumnHeader.
  • SortIndicatorMargin—Defines the margin of the sort indicator part of the ColumnHeader.
  • SortIndicatorAscendingText—Defines the text of the sort indicator when the sorting is ascending.
  • SortIndicatorDescendingText—Defines the text of the sort indicator when the sorting is descending.

By default, the indicator is represented by a string symbol that can be changed by using the IndicatorText and IndicatorFontFamily properties. For more details, refer to the article on sorting the DataGrid.

OptionsButton Styling

OptionsButton (three dots) is visualized only on Android and iOS. The button opens the built-in filtering UI.

Style the OptionsButton using the following properties:

  • OptionsButtonTextColor—Defines the color for the option indicator part of the ColumnHeader.
  • OptionsButtonText—Defines the text for the option indicator part of the ColumnHeader.
  • OptionsButtonMargin—Defines the margin of the option indicator part of the ColumnHeader.
  • Font Options(OptionsButtonFontAttributes, OptionsButtonFontFamily, OptionsButtonFontSize)—Define the font options to the option indicator text.

FilterIndicator Styling

On Mobile (Android and iOS)—FilterIndicator is shown once the RadDataGridColumnHeader is filtered.

On Desktop(MacCatalyst and Windows)—FilterIndicator is shown by default.

Style the FilterIndicator using the following properties:

  • FilterIndicatorTextColor—Defines the color for the filter indicator part of the ColumnHeader.
  • FilterIndicatorText—Defines the text for the filter indicator part of the ColumnHeader.
  • FilterIndicatorMargin—Defines the margin of the filter indicator part of the ColumnHeader.
  • Font Options(FilterIndicatorFontAttributes, FilterIndicatorFontFamily, FilterIndicatorFontSize)—Define the font options to the filter indicator text.

CellContentStyle

The CellContentStyle property defines the appearance of each cell associated with the column. The target type of the Style object depends on the type of the column. For example, for DataGridTextColumn it will be of the TextBlock type. You can go to the Column Types section, for example, to check the TargetType of each column type.

The following properties can be used to define the style of the text cell elements:

  • Font options (FontAttributes, FontFamily, FontSize)— Define the font of the cell text.
  • TextColor/SelectedTextColor—Define the color of the cells text. You can set a different value for the selected cell.
  • Text alignment (TextMargin, HorizontalTextAlignment, VerticalTextAlignment)—Define the positioning of the text inside the cell.

Here is an example how to set the CellContentStyle property:

<telerik:DataGridTextColumn.CellContentStyle>
    <telerik:DataGridTextCellStyle TextColor="DarkOliveGreen"
                                   FontSize="12"
                                   TextMargin="2"
                                   VerticalTextAlignment="Center" 
                                   HorizontalTextAlignment="Center"
                                   SelectedTextColor="Brown">
    </telerik:DataGridTextCellStyle>
</telerik:DataGridTextColumn.CellContentStyle>

CellDecorationStyle

To style the border of each cell associated with the column the CellDecorationStyle property is used. CellDecorationStyle is of type DataGridBorderStyle which provides the following properties—BackgroundColor, BorderColor, BorderTickness.

Here is an example how to set those properties on a column:

<telerik:DataGridTextColumn.CellDecorationStyle>
    <telerik:DataGridBorderStyle BorderColor="DarkBlue"  
                                 BorderThickness="3" 
                                 BackgroundColor="LightBlue" />
</telerik:DataGridTextColumn.CellDecorationStyle>

CellEditorStyle

CellEditorStyle defines the style that will be applied to the cell editor.

Here is an example how to set this property:

<telerik:DataGridTextColumn.CellEditorStyle>
    <Style TargetType="Entry">
        <Setter Property="FontSize" Value="Large"/>
        <Setter Property="FontAttributes" Value="Bold"/>
    </Style>
</telerik:DataGridTextColumn.CellEditorStyle>

And this is how the column style looks when the properties for customizing the column are applied:

DataGrid Columns Styling

FooterStyle

FooterStyle defines the appearance of the column footer. The DataGridColumnFooterStyle exposes the following properties for styling:

  • TextColor and BackgroundColor—Define the colors of the text part/background respectively.
  • BorderColor and BorderThickness—Define the style of the border around the column footer.
  • Font Options (TextFontFamily, TextFontAttributes, TextFontSize)—Define the font options to the text part of the ColumnFooter.
  • Text Alignment (TextMargin, HorizontalTextAlignment, VerticalTextAlignment)—Define the positioning for the text part of the ColumnFooter.
<telerik:DataGridTextColumn.FooterStyle>
    <telerik:DataGridColumnFooterStyle BackgroundColor="BlueViolet"
                                       TextColor="White"
                                       TextFontSize="16"
                                       BorderColor="Blue"
                                       BorderThickness="2"/>
</telerik:DataGridTextColumn.FooterStyle>

DataGrid Column Footer

See Also

In this article
Not finding the help you need?