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

Changing the font style of telerik Silverlight GridViewHeaderCell overwrites the implicit style

4 Answers 54 Views
GridView
This is a migrated thread and some comments may be shown as answers.
farizvi
Top achievements
Rank 1
farizvi asked on 01 Sep 2015, 08:03 AM
I have defined an implicit style for telerik GridViewHeaderCell which changes the background color for header cells of all grids used in the application. On some screens the caption of GridViewHeaderCell is formatted to be Bold by defining the style in that specific xaml file. This change of font overwrites the implicit GridViewHeaderCell styles applying the default Office Black style. My implicit style is given below

       
<Style TargetType="telerik:GridViewHeaderCell">       
        <Setter Property="Background" Value="{StaticResource GridView_HeaderBackground}"/>
        <Setter Property="BorderBrush" Value="{StaticResource GridView_HeaderOuterBorder}"/>
        <Setter Property="BorderThickness" Value="0 0 0 0"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
        <Setter Property="Padding" Value="5 0 3 0"/>      
        <Setter Property="Foreground" Value="{StaticResource GridView_HeaderForeground}"/>
    </Style>


Following is the style which is defined for making the caption bold

   
<Style x:Key="BoldFontStyle"
               TargetType="c:Control">
            <Setter Property="FontWeight" Value="Bold" />
</Style>


Is there any way to stop the BoldFontStyle from overwriting the implicit style? I know it can be fixed by making Background transparent for BoldFontStyle but in that case the change has to be implemented on every screen where this BoldFontStyle is defined. I don't want to follow that approach.

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 03 Sep 2015, 02:56 PM
Hello,

As it turns out targeting Control, this is the most basic Style. Would you try specifying a FontWeight like so:
<Style TargetType="telerik:GridViewHeaderCell">
    <Setter Property="BorderThickness" Value="0 0 0 0"/>
    <Setter Property="VerticalContentAlignment" Value="Center"/>
    <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    <Setter Property="Padding" Value="5 0 3 0"/>
    <Setter Property="Control.FontWeight" Value="ExtraLight"/>
</Style>

Regards,
Dimitrina
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
farizvi
Top achievements
Rank 1
answered on 03 Sep 2015, 03:14 PM
Isn't there any way to stop the Bold style from overwriting the GridViewHeaderCell style? I cannot include the bold style in GridViewHeaderCell style as only a few columns have caption in bold. Not all of them
0
farizvi
Top achievements
Rank 1
answered on 03 Sep 2015, 03:37 PM
Is it possible to apply style conditionally?
0
Dimitrina
Telerik team
answered on 04 Sep 2015, 12:33 PM
Hi,

As it turns out there is not a single property to configure. You will need to override the Style applied globally on a local level.
One way would be to define an Empty Style targeting the Control element on the needed scope.

<telerik:RadGridView.Resources>
    <Style TargetType="c:Control" />
</telerik:RadGridView.Resources>

Regards,
Dimitrina
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
Tags
GridView
Asked by
farizvi
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
farizvi
Top achievements
Rank 1
Share this question
or