Please help...
I am trying to change the foreground colour of the header cell. From what I can see from your help notes, I need to add a dummy GridviewHeaderCell and create a template and a style for it which I then use as the HeaderCellStyle of the GridViewDataColumn.
When the style is applied GridviewHeaderCell, both the foreground and background colours are applied correctly but when applied to the HeaderCellStyle of the GridViewDataColumn, I get the background colour to change to what I set in the style, but the foreground colour remains black.
Kind regards
The XAML is pasted below
13 Answers, 1 is accepted
You need to add a style to your resources targeting the GridViewHeader cell e.g.
<
Style
TargetType
=
"gridView:GridViewHeaderCell"
x:Key
=
"MyHeaderCellStyle"
>
<
Setter
Property
=
"Foreground"
Value
=
"Green"
/>
</
Style
>
then you use it like that :
<grid:GridViewDataColumn HeaderCellStyle="{StaticResource MyHeaderCellStyle}"
Kind regards,
Pavel Pavlov
the Telerik team
Thank you very much for your response.
I have used the example you supplied, but the foreground of the header cell remains black, no matter what I do in the HeaderCellStyle. An example of the XAML follows and I also attach a picture of the result.
Please advise.
Kind regards
....
<UserControl.Resources>
<Style TargetType="telerik:GridViewHeaderCell" x:Key="MyHeaderCellStyle">
<Setter Property="Foreground" Value="White"/>
<Setter Property="Background" Value="Blue"/>
</Style>
</UserControl.Resources>
<Grid DataContext="{Binding Source={StaticResource DXEmployeesSampleDataSource}}">
<telerik:RadGridView d:LayoutOverrides="Width, Height">
<telerik:RadGridView.Columns>
<telerik:GridViewDataColumn
HeaderCellStyle="{StaticResource MyHeaderCellStyle}"
Header="This must be white"/>
</telerik:RadGridView.Columns>
</telerik:RadGridView>
</Grid>
</UserControl>
I have tested it here and it worked for me. Maybe we are testing with different versions of the Telerik dlls ?
Please let me know the version you are using and the target framework version ( SL 3 or SL 4 ) and I will send a working sample.
Best wishes,
Pavel Pavlov
the Telerik team
I am using Silverlight 4 and Telerik version 2010.1.603.1040.
Kind regards
I am sending you a sample that changes the Background,Foreground,FontSize,FontWeight of a GridViewHeaderCell within a simple style.
Best wishes,
Vanya Pavlova
the Telerik team
Even after adding this style my grid header cells foreground color won't change to white.
<Grid.Resources>
<Style TargetType="telerik:GridViewHeaderCell">
<Setter Property="Foreground" Value="White" />
</Style>
</Grid.Resources>
I am adding the radgridview in my codebehind.
Please have a look at the screenshot.
Thanks & Regards,
Keerti Somasundaram
To add more information , when i set my background and foreground to other colors am able to see the style getting changed , but i am not able to see the white foreground color.
Any help is greatly appreciated.
Thanks & Regards,
Keerti Somasundaram
Thank you for sharing this screenshot to us. May you verify that you don't have defined an implicit style targeted at a TextBlock element in your project?
Please check it and let me know how I can assist you further.
Vanya Pavlova
the Telerik team
No , we do not have any implicit styles defined for textblock element.
And as i had mentioned to you in my previous post , only with white this problem occurs ,
if i set a gray background and a black foreground am able to see the style getting set.
Probably i am missing something. Have a look at this screenshot below with gray background.
Thanks & Regards,
Keerti Somasundaram
Thank you for sending this picture to us. By default the foreground of a GridViewHeaderCell is White and even if you set only the background of the GridViewHeaderCell to Gray in a simple style everything should be displayed correctly - white foreground, gray background. From the previously attached picture I may see that the background of the header cell is the default one and the foreground is black too.
In order to avoind any misunderstandings I believe that it would be better to send us in a new support ticket a small repro application with the style defined where we can see what might be causing this behavior, also you may check the attached project for further reference.
I am waiting for your response.
Greetings,
Vanya Pavlova
the Telerik team
<Style
TargetType="telerik:GridViewHeaderCell">
<Setter Property="Template" Value="{StaticResource GridViewHeaderCellTemplate}" />
<Setter Property="Background" Value="{StaticResource RadCellGridView_HeaderBackground}" />
<Setter Property="BorderBrush" Value="{StaticResource RadCellGridView_HeaderOuterBorder}" />
<Setter Property="BorderThickness" Value="0,0,1,1" />
<Setter Property="VerticalContentAlignment" Value="Center" />
<Setter Property="HorizontalContentAlignment" Value="Stretch" />
<Setter Property="Padding" Value="5,0,3,0" />
<Setter Property="Foreground" Value="{StaticResource RadCellGridView_HeaderForeground}" />
</Style>
this did not change my foreground to black, why?
and allso as you can see in the myraddatagridview.png attach file.
another question wich style & property must I customize to change the groupby background? as you can see in the file it is gray, I want it orange.
allso the groupby makes this extra widths blocks in the right and left side it should almost look like the next attach file - myraddatagridview2, why is there this extra blocks?
I have just posted an answer to this inquiry in the other thread. Please, let us carry out any further communication there, in order to achieve a fruitful and consistent dialogue.
Regards,
Ivan Ivanov
the Telerik team