Articles in this section
Category / Section

How to apply custom style for GridHeaderCellControl in UWP ?

2 mins read

SfDataGrid displays the column header in GridHeaderCellControl that displays the column Header Text, filter icon and sort icon when you sort the column. You can apply the custom style for GridHeaderCellControl by using HeaderStyle property.

You can change the header cell Background and Foreground for specific column or an entire Grid by using HeaderStyle property.

Following code example illustrates the custom header style applied for GridHeaderCellControl present in the Grid.

XAML

  <Window.Resources>
        <Style TargetType="syncfusion:GridHeaderCellControl" x:Key="headerStyle">
            <Setter Property="Background" Value="#FF7AA732"/>
            <Setter Property="Foreground" Value="Red"/>
        </Style>
   </Window.Resources> 
<!--Apply style for GridHeaderCellControl present in the grid-->
 <syncfusion:SfDataGrid x:Name="grid"       
                               HeaderStyle="{StaticResource headerStyle}" 
                               ItemsSource="{Binding Students}"  
                               ColumnSizer="Star"
                               AllowEditing="True">

The following screenshot displays the column header with customized column header style.

C:\Users\Jayapradha\Desktop\headerstyle.PNG

Figure 1: Column header with customized column header style

The following code example illustrates the custom header style applied for specific column Header.

XAML

  <Window.Resources>
        <Style TargetType="syncfusion:GridHeaderCellControl" x:Key="headerStyle">
            <Setter Property="Background" Value="#FF7AA732"/>
            <Setter Property="Foreground" Value="Red"/>
        </Style>
   </Window.Resources> 
<syncfusion:SfDataGrid.Columns>
 <!--Change the HeaderStyle for specific column-->
<syncfusion:GridTextColumn MappingName="ProductId" 
                                               HeaderStyle="{StaticResource headerStyle}"/>
</syncfusion:SfDataGrid.Columns>

The following screenshot displays the customized HeaderStyle for specific column.

C:\Users\Jayapradha\Desktop\columnheaderstyle.PNG

Figure 2: Customized HeaderStyle for specific column

 

Sample Links:

 

WPF

WRT

SilverLight

UWP

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment