2

Need some help about this one. I have a Telerik:RadGridView control and define the GridViewHeaderCell style of it in the resources

<Window.Resources>
   <LinearGradientBrush x:Key="HeaderBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFEBCD97" Offset="0.028"/>
        <GradientStop Color="#FFC89C22" Offset="1"/>
        <GradientStop Color="#FFC2AA39" Offset="0.452"/>
        <GradientStop Color="#FFC49B2A" Offset="0.676"/>
        <GradientStop Color="#FFCCB073" Offset="0.404"/>
        <GradientStop Color="White" Offset="0"/>
    </LinearGradientBrush>


   <Style TargetType="{x:Type telerik:GridViewHeaderCell}" x:Key="HeaderStyle">
        <Setter Property="Background" Value="{DynamicResource HeaderBrush}" />
    </Style>
</Window.Resources>

But I can't access the HeaderStyle in my RadGridView to set the style of it

<telerik:RadGridView Name="radGridView1"  HeaderCellStyle="{StaticResource HeaderStyle}"  Loaded="radGridView1_Loaded_1"/>

This is a WPF Application and is there HeaderCellStyle property of RadGridView in WPF? Or am I missing telerik library that needs to be referenced? Thanks in advance.

lincx
  • 399
  • 2
  • 5
  • 15

1 Answers1

1

The HeaderCellStyle is present in RadControls for WPF RadGridView. But its supported on a GridViewDataColumn or GridViewColumn level. Its not available on RadGridView level. You would need to add explicitly the gridview columns for your rad grid view and then add the headercellstyle. Here is what i was able to put together quickly.

<telerik:RadGridView x:Name="radGridView" AutoGenerateColumns="False">
        <telerik:RadGridView.Columns>
            <telerik:GridViewDataColumn Header="First Name" DataMemberBinding="{Binding FirstName}" HeaderCellStyle="{StaticResource HeaderStyle}" />
            <telerik:GridViewDataColumn Header="Last Name" DataMemberBinding="{Binding LastName}" HeaderCellStyle="{StaticResource HeaderStyle}" />
            <telerik:GridViewDataColumn Header="Title" DataMemberBinding="{Binding Title}" HeaderCellStyle="{StaticResource HeaderStyle}" />
            <telerik:GridViewDataColumn Header="City" DataMemberBinding="{Binding City}" HeaderCellStyle="{StaticResource HeaderStyle}" />
            <telerik:GridViewDataColumn Header="Country" DataMemberBinding="{Binding Country}" HeaderCellStyle="{StaticResource HeaderStyle}" />

        </telerik:RadGridView.Columns>
    </telerik:RadGridView>

I have used the same styling you have provided and applied it to each column headers.

Here is the output:

RadGridView Header Styling

Hope i was able to answer your question

Lohith (Tech Evangelist, Telerik India)

kashyapa
  • 1,606
  • 1
  • 10
  • 13