Styling the Column Headers

Before reading this topic, you might find useful to get familiar with the Template Structure of the GridViewHeaderCell control.

RadGridView's Header Cells can be styled by creating an appropriate Style and setting it to the HeaderCellStyle property of the GridViewColumns.

You have two options:

  • To create an empty style and set it up on your own.

  • To copy the default style of the control and modify it.

This topic will show you how to perform the second one.

Modifying the Default Style

GridViewHeaderCell control is located in the Telerik.Windows.Controls.GridView namespace of Telerik.Windows.Controls.GridView assembly.

When working in Expression Blend, the namespaces that are needed will be added automatically.

Load your project in Expression Blend and open the User Control that holds the RadGridView. You have to use a dummy control in order to get the default style. To create one find the GridViewHeaderCell control in the 'Assets' and draw one on the art board. In the 'Objects and Timeline' pane select the __GridViewHeaderCell__that you've drawn and from the menu choose Object -> Edit Style -> Edit a Copy. You will be prompted for the name of the style and where to be placed.

If you choose to define the style in Application, it would be available for the entire application. This allows you to define a style only once and then reuse it where needed.

After clicking 'OK', Expression Blend will generate the default style of the GridViewHeaderCell control in the Resources section of your User Control. The properties available for the style will be loaded in the 'Properties' pane and you will be able to modify their default values. You can also edit the generated XAML in the XAML View or in Visual Studio.

  • GridView_HeaderInnerBorder - a brush that represents the outer border color of the header.

  • GridView_HeaderOuterBorder_Over - a brush that represents the outer border color of the header, when the mouse is over it.

  • GridView_HeaderBackground_Over - a brush that represents the background color of the header, when the mouse is over it.

  • GridView_HeaderInnerBorder_Over - a brush that represents the inner border color of the header, when the mouse is over it.

  • GridView_HeaderOuterBorder_Selected- a brush that represents the outer border color of the header, when it is selected.

  • GridView_HeaderBackground_Selected - a brush that represents the background color of the header, when it is selected.

  • GridView_HeaderInnerBorder_Selected - a brush that represents the inner border color of the header, when it is selected.

  • GridView_SortIndicatorColor - a brush that represents the background color of the sort indicator.

  • ColumnHeaderGripperStyle - the Style applied to the ColumnHeaderGripper control.

  • GridView_HeaderForeground_Selected - a brush that represents the foreground color of the header, when the mouse is over it and when it is selected.

  • GridViewHeaderCellTemplate - the ControlTemplate, applied to the GridViewCell.

  • GridView_HeaderBackground - a brush that represents the background color of the header.

  • GridView_HeaderOuterBorder - a brush that represents the outer border color of the header.

  • GridView_HeaderForeground - a brush that represents the foreground color of the header.

  • GridViewHeaderCellStyle - the Style, applied to the GridViewHeaderCell control.

To apply the style to the real headers, set it to the HeaderCellStyle property of the RadGridView columns.

XAML

<telerik:GridViewDataColumn Header="ID"
                            DataMemberBinding="{Binding EmployeeID}"
                            HeaderCellStyle="{StaticResource GridViewHeaderCellStyle}" />

Don't forget to delete the dummy GridViewHeaderCell control, when you finish editing the style.

And here is a snapshot of the result.

See Also