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

5 posts, 0 answers
  1. farizvi
    farizvi avatar
    8 posts
    Member since:
    Feb 2007

    Posted 01 Sep 2015 Link to this post

    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.
  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 03 Sep 2015 Link to this post

    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
  3. DevCraft banner
  4. farizvi
    farizvi avatar
    8 posts
    Member since:
    Feb 2007

    Posted 03 Sep 2015 in reply to Dimitrina Link to this post

    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
  5. farizvi
    farizvi avatar
    8 posts
    Member since:
    Feb 2007

    Posted 03 Sep 2015 Link to this post

    Is it possible to apply style conditionally?
  6. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 04 Sep 2015 Link to this post

    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
Back to Top
DevCraft banner