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

RadGridView: Changing colour of a sorted HeaderCell

3 Answers 171 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Kenneth
Top achievements
Rank 1
Kenneth asked on 09 Feb 2016, 10:00 AM

 

Greetings

Currently I'm not that experienced with styles in WPF and after some research I decided to give it a shot to ask. 

I'm working with with the RadGridView and I'd like to change the Foreground of the header of a sorted column. 

Within the styles of Telerik I found there are some visual states to determine the colour of the border or for the ascending/ descending arrow. Yet there is no description to change the colour of the Foreground. 

Yet doing some research, I found some code to add to change the Foreground as well within the VisualState. 

<ObjectAnimationUsingKeyFrames Storyboard.TargetName="Content" Storyboard.TargetProperty="(TextBlock.Foreground)">
    <DiscreteObjectKeyFrame KeyTime="0" Value="White" />
</ObjectAnimationUsingKeyFrames>

Yet, this isn't working. This entirely breaks the VisualState of 'Ascending'/ 'Descending' and the following exception within Output can be found:

A first chance exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll

Sorry for asking perhaps a dumb question. I'm still in the learning process of Telerik styles and WPF styles in general. 

Kind regards

Kenneth

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 12 Feb 2016, 09:38 AM
Hi Kenneth,

For achieving this, you need to modify the template of GridViewHeaderCell. I suggest you taking a look at the Implicit Styles topic, as well at the Styling Column Headers one for more information on this matter.

So, within the ControlTemplate of GridViewHeaderCell you should be able to find the two VisualStates with x:Name="Ascending" and x:Name="Descending". Both of them use the SolidColorBrush with x:Key="GridView_HeaderForeground_Selected". You can modify it as per your requirements.

I have also attached a sample application as a demonstration.

Hope it helps.

Regards,
Stefan X1
Telerik
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 Feedback Portal and vote to affect the priority of the items
0
Mark
Top achievements
Rank 1
answered on 22 Jun 2016, 11:48 AM
This post was very helpful to me thank you!
0
Mark
Top achievements
Rank 1
answered on 22 Jun 2016, 11:49 AM
This post was very helpful to me thank you!
Tags
GridView
Asked by
Kenneth
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Mark
Top achievements
Rank 1
Share this question
or