This is a migrated thread and some comments may be shown as answers.

[Solved] Changing Header Cell Color

3 Answers 119 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Keith Stephens
Top achievements
Rank 1
Keith Stephens asked on 10 Sep 2010, 04:03 PM
Hello all,

I have searched for this, but could not find a simple exapmle of what I am trying to do.

I have a gridview and I need to change the header color of just some of the header cells. Some need to be blue and some red.

Also some of the datacolumn use the header property and some use.  Also I do not have expression blend so that is no help to me right now.
<telerikGridView:GridViewDataColumn.Header>
                                            <StackPanel Orientation="Vertical">
                                                <TextBlock Text="Cost" HorizontalAlignment="Center" />
                                                <TextBlock Text="Rate" HorizontalAlignment="Center" />
                                            </StackPanel>
                                        </telerikGridView:GridViewDataColumn.Header>

Thanks,
KS

3 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 13 Sep 2010, 08:29 AM
Hi Keith Stephens,

You can easily achieve this result without using Blend  if you define a HeaderCellStyle for your columns as you can see in the following code snippet:
<telerik:GridViewDataColumn  DataMemberBinding="{Binding Property1}">
  <telerik:GridViewDataColumn.Header>
       <StackPanel Orientation="Vertical">
       <TextBlock Text="Cost" HorizontalAlignment="Center"/>
          <TextBlock Text="Rate" HorizontalAlignment="Center"/>
       </StackPanel>
  </telerik:GridViewDataColumn.Header>
  <telerik:GridViewDataColumn.HeaderCellStyle>
   <Style TargetType="telerik:GridViewHeaderCell">
       <Setter Property="Background" Value="Red"/>
       <Setter Property="Foreground" Value="Black"/>
     <Setter Property="FontSize" Value="20"/>
    </Style>
</telerik:GridViewDataColumn.HeaderCellStyle>
</telerik:GridViewDataColumn>

Sincerely yours,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Keith Stephens
Top achievements
Rank 1
answered on 13 Sep 2010, 02:12 PM
is there a way to use color codes?

D7E4BC - greenish color
FFFFCC - yellowish color

Also could you explain to me what the difference is in the following 2 assemblies?
In order for me to see the HeaderCellStyle I had to add the xmlns:telerikGridView1 name space.

xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls.GridView"
xmlns:telerikGridView1="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"

Thanks,
KS
0
Accepted
Vanya Pavlova
Telerik team
answered on 14 Sep 2010, 09:42 AM
Hi Keith Stephens,

Yes you can use the hexadecimal representation of the colours,please refer to the following:
<Setter Property="Background" Value="#FFD7E4BC"/> 
To answer to your the second question there are some differences between these namespaces,beause there are elements that are missing in the first namespace,but they are available for use in the second namespace.
Please let me know if you need any further assistance.

All the best,
Vanya Pavlova
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Keith Stephens
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Keith Stephens
Top achievements
Rank 1
Share this question
or