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

Setting HeaderCellStyle Foreground doesn't work

8 Answers 130 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Raffaele
Top achievements
Rank 1
Raffaele asked on 03 May 2011, 09:25 AM
After updating Silverlight Controls to the latest version, setting the HeaderCellStyle Foreground doesn't change the header text color

<telerik:GridViewDataColumn.HeaderCellStyle>
    <Style TargetType="telerik:GridViewHeaderCell">
        <Setter Property="Background" Value="Red"/>
        <Setter Property="Foreground" Value="White"/>
        <Setter Property="FontSize" Value="20"/>
    </Style>
</telerik:GridViewDataColumn.HeaderCellStyle>

8 Answers, 1 is accepted

Sort by
0
Ivan Ivanov
Telerik team
answered on 03 May 2011, 09:55 AM
Hi Raffaele,

Would you please confirm the version of RadControls that you are using? I tested this code with 2011.1.419 assemblies and it worked as expected. Please, refer to the attached project and inform us if you are experiencing such a behavior when operating with it.

All the best,
Ivan Ivanov
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
Raffaele
Top achievements
Rank 1
answered on 03 May 2011, 10:41 AM
Ok, I fix the problem in my style.

Can you suggest me how can I change the color of the text in the grid (not the header)?
0
Ivan Ivanov
Telerik team
answered on 03 May 2011, 11:45 AM
Hi Raffaele,

You should set the Foreground property like this:
<telerik:RadGridView Foreground="Blue" ... />


Best wishes,
Ivan Ivanov
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
Raffaele
Top achievements
Rank 1
answered on 03 May 2011, 01:49 PM
Hi,

if I define an implicit style for the TextBlock type, the Foreground color is not applied to the row text.
0
Ivan Ivanov
Telerik team
answered on 03 May 2011, 02:12 PM
Hi Raffaele,

I am not sure wether I understand your requirements properly. Could you please shed some more light on them. Which TextBoxes do you want to style? If you aim at changing GridviewRows' foreground. You may define an implicit style targetting GridViewRow:

<Style TargetType="telerik:GridViewRow">
    <Setter Property="Foreground" Value="Blue" />
</Style>


All the best,
Ivan Ivanov
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
Ivan Ivanov
Telerik team
answered on 03 May 2011, 02:33 PM
Hi Raffaele,

Setting an implicit style, targeting the TextBlock type should affect all the TextBlocks in RadGridViews templates, including these in the cells. This will also affect all of the GridVeiwHeaderCells, but as far as I have understood your requirements, you want to prevent styling  the headers, am I right? As for the TextBlock implicit style, are you sure that you are not trying to set multiple styles that target this type?

Best wishes,
Ivan Ivanov
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
Raffaele
Top achievements
Rank 1
answered on 03 May 2011, 02:43 PM
I have an implicit style at app.xaml level that define a foreground color White for the TextBlock.

As default this doesn't look good on your grid because the background color of rows is also white, so I cannot read the text. In this scenatio, I am not able to set the color of the text inside the row to black (leaving the color of the header text to white) because it use the color defined in the implicit style, also if I specify a foreground color black in the grid or in the gridrowstyle
0
Ivan Ivanov
Telerik team
answered on 03 May 2011, 04:13 PM
Hi Raffaele,

This is an expected behavior, since you cannot set more than one style to an element. Your style in App.xaml sets all the TextBlocks' Foreground property to white and the other styles are not respected. In order to prevent it, you may try resetting the style on RadGridView's RowLoaded event. Please, refer to the attached example for more extensive information. 

Kind regards,
Ivan Ivanov
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
Raffaele
Top achievements
Rank 1
Answers by
Ivan Ivanov
Telerik team
Raffaele
Top achievements
Rank 1
Share this question
or