Rad GridView Header Foreground Colour

14 posts, 0 answers
  1. Wimpie Schoeman
    Wimpie Schoeman avatar
    7 posts
    Member since:
    Jun 2010

    Posted 22 Jul 2010 Link to this post

    Hi there

    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

    <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                 xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
                 xmlns:VIPLite_EmployeeBits="clr-namespace:VIPLite.EmployeeBits"
                 xmlns:commands="clr-namespace:Microsoft.Practices.Composite.Presentation.Commands;assembly=Microsoft.Practices.Composite.Presentation"
                 xmlns:dataInput="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data.Input"
                 xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
                 xmlns:ic="clr-namespace:Microsoft.Expression.Interactivity.Core;assembly=Microsoft.Expression.Interactions"
                 xmlns:ie="clr-namespace:Microsoft.Expression.Interactivity;assembly=Microsoft.Expression.Interactivity"
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                 xmlns:VIPLite="clr-namespace:VIPLite.Behaviors;assembly=VIPLite.Behaviors"
                 xmlns:gp="clr-namespace:GridProperties"
                 xmlns:controlsToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Toolkit"
                 xmlns:dataPrimitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Data"
                 xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows"
    xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
                 xmlns:customcontrols="clr-namespace:VIPLite.Controls.CustomControls;assembly=VIPLite.Controls"
                
                          xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk" xmlns:System_Windows_Controls_Primitives="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls"
                 xmlns:VIPLite_Controls="clr-namespace:VIPLite.Controls;assembly=VIPLite.Controls"
                 xmlns:System="clr-namespace:System;assembly=mscorlib"
                 xmlns:layoutToolkit="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Layout.Toolkit"
                 xmlns:layoutPrimitivesToolkit="clr-namespace:System.Windows.Controls.Primitives;assembly=System.Windows.Controls.Layout.Toolkit"
                 xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
    xmlns:telerik2="clr-namespace:Telerik.Windows.Controls;assembly=Telerik.Windows.Controls" 
                 xmlns:Telerik_Windows_Controls_MaskedTextBox="clr-namespace:Telerik.Windows.Controls.MaskedTextBox;assembly=Telerik.Windows.Controls.Input" xmlns:Telerik_Windows_Controls_Chromes="clr-namespace:Telerik.Windows.Controls.Chromes;assembly=Telerik.Windows.Controls" 
                 xmlns:VIPLite_Controls1="clr-namespace:VIPLite.Controls;assembly=VIPLite.Core" 
                 mc:Ignorable="d"
                
                          x:Class="My_TextApp.MainPage" HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch"
                         >

     <UserControl.Resources>
     
      <DataTemplate x:Key="DataTemplate1">
      <Grid Background="{StaticResource GrayBrush}"/>
      </DataTemplate>
      <SolidColorBrush x:Key="GridView_HeaderInnerBorder" Color="#FF4B4B4B"/>
      <SolidColorBrush x:Key="GridView_HeaderOuterBorder_Over" Color="#FFFFC92B"/>
      <SolidColorBrush x:Key="GridView_HeaderInnerBorder_Over" Color="White"/>
      <LinearGradientBrush x:Key="GridView_HeaderBackground_Over" EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#FFFFFBA3" Offset="1"/>
      <GradientStop Color="#FFFFFBDA" Offset="0"/>
      <GradientStop Color="#FFFFD25A" Offset="0.43"/>
      <GradientStop Color="#FFFEEBAE" Offset="0.42"/>
      </LinearGradientBrush>
      <LinearGradientBrush x:Key="GridView_HeaderOuterBorder_Selected" EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#FF616161" Offset="0"/>
      <GradientStop Color="#FF989898" Offset="1"/>
      </LinearGradientBrush>
      <LinearGradientBrush x:Key="GridView_HeaderInnerBorder_Selected" EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#FFB69A78"/>
      <GradientStop Color="#FFFFE17A" Offset="0.126"/>
      </LinearGradientBrush>
      <LinearGradientBrush x:Key="GridView_HeaderBackground_Selected" EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#FFFFD74E" Offset="0.996"/>
      <GradientStop Color="#FFFFDCAB" Offset="0.17"/>
      <GradientStop Color="#FFFFB062" Offset="0.57"/>
      <GradientStop Color="#FFFFD18F" Offset="0.56"/>
      <GradientStop Color="#FFFFBA74"/>
      </LinearGradientBrush>
      <Style x:Key="StretchedContentControl" TargetType="ContentControl">
      <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
      <Setter Property="VerticalContentAlignment" Value="Stretch"/>
      </Style>
      <SolidColorBrush x:Key="GridView_SortIndicatorColor" Color="Black"/>
      <telerik2:Office_BlackTheme x:Key="Theme"/>
      <Style x:Key="ColumnHeaderGripperStyle" TargetType="Thumb">
      <Setter Property="Width" Value="8"/>
      <Setter Property="Background" Value="Transparent"/>
      <Setter Property="BorderBrush" Value="Transparent"/>
      <Setter Property="BorderThickness" Value="0"/>
      <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
      <Setter Property="VerticalContentAlignment" Value="Stretch"/>
      <Setter Property="Padding" Value="0"/>
      <Setter Property="Cursor" Value="SizeWE"/>
      <Setter Property="Template">
      <Setter.Value>
      <ControlTemplate TargetType="Thumb">
      <Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
      </ControlTemplate>
      </Setter.Value>
      </Setter>
      </Style>
      <SolidColorBrush x:Key="GridView_HeaderForeground_Selected" Color="Black"/>
      <ControlTemplate x:Key="GridViewHeaderCellTemplate" 
    TargetType="telerik:GridViewHeaderCell">
      <Grid x:Name="PART_HeaderCellGrid">
      <Grid.ColumnDefinitions>
      <ColumnDefinition Width="*"/>
      <ColumnDefinition Width="Auto"/>
      </Grid.ColumnDefinitions>
      <VisualStateManager.VisualStateGroups>
      <VisualStateGroup x:Name="CommonStates">
      <VisualStateGroup.Transitions>
      <VisualTransition GeneratedDuration="00:00:00.2000000" To="Normal"/>
      <VisualTransition GeneratedDuration="00:00:00.2000000" To="MouseOver"/>
      </VisualStateGroup.Transitions>
      <VisualState x:Name="Normal"/>
      <VisualState x:Name="MouseOver">
      <Storyboard>
      <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="Opacity" Storyboard.TargetName="GridViewHeaderCell_Over">
      <EasingDoubleKeyFrame KeyTime="0:0:0" Value="1"/>
      </DoubleAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_HeaderForeground_Selected}"/>
      </ObjectAnimationUsingKeyFrames>
      </Storyboard>
      </VisualState>
      <VisualState x:Name="Ascending">
      <Storyboard>
      <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_HeaderForeground_Selected}"/>
      </ObjectAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_SortIndicator">
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="1"/>
      </ObjectAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="GridViewHeaderCell_Selected">
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="1"/>
      </ObjectAnimationUsingKeyFrames>
      </Storyboard>
      </VisualState>
      <VisualState x:Name="Descending">
      <Storyboard>
      <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Duration="00:00:00.0010000" Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter">
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="{StaticResource GridView_HeaderForeground_Selected}"/>
      </ObjectAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_SortIndicator">
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="1"/>
      </ObjectAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="RenderTransform" Storyboard.TargetName="PART_SortIndicator">
      <DiscreteObjectKeyFrame KeyTime="0:0:0">
      <DiscreteObjectKeyFrame.Value>
      <ScaleTransform ScaleY="1" ScaleX="1"/>
      </DiscreteObjectKeyFrame.Value>
      </DiscreteObjectKeyFrame>
      </ObjectAnimationUsingKeyFrames>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="GridViewHeaderCell_Selected">
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="1"/>
      </ObjectAnimationUsingKeyFrames>
      </Storyboard>
      </VisualState>
      </VisualStateGroup>
      </VisualStateManager.VisualStateGroups>
      <Border x:Name="GridViewHeaderCell" 
    BorderBrush="{TemplateBinding BorderBrush}" 
    BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2">
      <Border BorderBrush="{StaticResource GridView_HeaderInnerBorder}" 
    BorderThickness="1" 
    Background="{TemplateBinding Background}"/>
      </Border>
      <Border x:Name="GridViewHeaderCell_Over" BorderBrush="{StaticResource GridView_HeaderOuterBorder_Over}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" Opacity="0">
      <Border BorderBrush="{StaticResource GridView_HeaderInnerBorder_Over}" BorderThickness="1" Background="{StaticResource GridView_HeaderBackground_Over}"/>
      </Border>
      <Border x:Name="GridViewHeaderCell_Selected" BorderBrush="{StaticResource GridView_HeaderOuterBorder_Selected}" BorderThickness="{TemplateBinding BorderThickness}" Grid.ColumnSpan="2" Opacity="0">
      <Border BorderBrush="{StaticResource GridView_HeaderInnerBorder_Selected}" BorderThickness="1" Background="{StaticResource GridView_HeaderBackground_Selected}"/>
      </Border>
      <ContentControl x:Name="ContentPresenter" 
    ContentTemplate="{TemplateBinding ContentTemplate}" 
    Content="{TemplateBinding Content}" Grid.Column="0" 
    Foreground="White" 
    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
    Margin="{TemplateBinding Padding}"
    Style="{StaticResource StretchedContentControl}" 
    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
      <Path x:Name="PART_SortIndicator" Grid.ColumnSpan="2" Data="M0,0 L1,0 2,0 3,0 4,0 5,0 5,1 4,1 4,2 3,2 3,3 2,3 2,2 1,2 1,1 0,1 0,0 z" Fill="{StaticResource GridView_SortIndicatorColor}" HorizontalAlignment="Center" Height="3" Margin="0,3,0,0" Opacity="0" RenderTransformOrigin=".5,.5" Stretch="Fill" VerticalAlignment="Top" Width="5">
      <Path.RenderTransform>
      <TransformGroup>
      <ScaleTransform ScaleY="-1" ScaleX="1"/>
      <SkewTransform AngleY="0" AngleX="0"/>
      <RotateTransform Angle="0"/>
      <TranslateTransform X="0" Y="0"/>
      </TransformGroup>
      </Path.RenderTransform>
      </Path>
      <telerik:FilteringDropDown x:Name="PART_DistinctFilterControl" Grid.Column="1" Margin="0,0,8,0" telerik2:StyleManager.Theme="{StaticResource Theme}" Visibility="{TemplateBinding FilteringUIVisibility}"/>
      <Thumb x:Name="PART_LeftHeaderGripper" Grid.ColumnSpan="2" HorizontalAlignment="Left" Style="{StaticResource ColumnHeaderGripperStyle}"/>
      <Thumb x:Name="PART_RightHeaderGripper" Grid.ColumnSpan="2" HorizontalAlignment="Right" Style="{StaticResource ColumnHeaderGripperStyle}"/>
      </Grid>
      </ControlTemplate>
      <LinearGradientBrush x:Key="GridView_HeaderBackground" EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#FF5B5B5B" Offset="1"/>
      <GradientStop Color="#FF868686"/>
      <GradientStop Color="#FF4F4F4F" Offset="0.42"/>
      <GradientStop Color="#FF0E0E0E" Offset="0.43"/>
      </LinearGradientBrush>
      <SolidColorBrush x:Key="GridView_HeaderOuterBorder" Color="#FF848484"/>
      <SolidColorBrush x:Key="GridView_HeaderForeground" Color="White"/>
      <Style x:Key="GridViewHeaderCellStyle1" TargetType="telerik:GridViewHeaderCell">
      <Setter Property="Template" Value="{StaticResource GridViewHeaderCellTemplate}"/>
      <Setter Property="Background" Value="{StaticResource DarkGreenBrush}"/>
      <Setter Property="BorderBrush" Value="{StaticResource GridView_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="HotPink"/>
      </Style>
      <SolidColorBrush x:Key="GridView_GroupPanelOuterBorder" Color="#FF848484"/>
      <telerik2:BooleanToVisibilityConverter x:Key="BooleanToVisibilityConverter"/>
      <ControlTemplate x:Key="GridViewDataControlTemplate" TargetType="telerik:GridViewDataControl">
      <Border x:Name="PART_MasterGridContainer" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}">
      <VisualStateManager.VisualStateGroups>
      <VisualStateGroup x:Name="GridViewActivity">
      <VisualState x:Name="Idle">
      <Storyboard>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="PART_GridViewLoadingIndicator">
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Collapsed"/>
      </ObjectAnimationUsingKeyFrames>
      </Storyboard>
      </VisualState>
      <VisualState x:Name="Busy">
      <Storyboard>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="PART_GridViewLoadingIndicator">
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Visible"/>
      </ObjectAnimationUsingKeyFrames>
      </Storyboard>
      </VisualState>
      </VisualStateGroup>
      <VisualStateGroup x:Name="ColumnHeadersVisibility">
      <VisualState x:Name="ColumnHeadersVisible"/>
      <VisualState x:Name="ColumnHeadersCollapsed">
      <Storyboard>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="PART_HeaderRow">
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Collapsed"/>
      </ObjectAnimationUsingKeyFrames>
      </Storyboard>
      </VisualState>
      </VisualStateGroup>
      <VisualStateGroup x:Name="ColumnFootersVisibility">
      <VisualState x:Name="ColumnFootersVisible"/>
      <VisualState x:Name="ColumnFootersCollapsed">
      <Storyboard>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="PART_FooterRow">
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Collapsed"/>
      </ObjectAnimationUsingKeyFrames>
      </Storyboard>
      </VisualState>
      </VisualStateGroup>
      <VisualStateGroup x:Name="GroupPanelVisibility">
      <VisualState x:Name="GroupPanelVisible"/>
      <VisualState x:Name="GroupPanelCollapsed">
      <Storyboard>
      <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="PART_GroupPanel">
      <DiscreteObjectKeyFrame KeyTime="0:0:0" Value="Collapsed"/>
      </ObjectAnimationUsingKeyFrames>
      </Storyboard>
      </VisualState>
      </VisualStateGroup>
      </VisualStateManager.VisualStateGroups>
      <Grid>
      <Grid.RowDefinitions>
      <RowDefinition Height="Auto"/>
      <RowDefinition Height="Auto"/>
      <RowDefinition/>
      <RowDefinition Height="Auto"/>
      </Grid.RowDefinitions>
      <telerik:GridViewGroupPanel x:Name="PART_GroupPanel" BorderBrush="{StaticResource GridView_GroupPanelOuterBorder}" Background="{TemplateBinding GroupPanelBackground}" Foreground="{TemplateBinding GroupPanelForeground}" telerik:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical" telerik2:StyleManager.Theme="{StaticResource Theme}"/>
      <StackPanel Grid.Row="1">
      <telerik:GridViewHeaderRow 
    x:Name="PART_HeaderRow" 
    IndentLevel="{TemplateBinding GroupCount}" 
    telerik:SelectiveScrollingGrid.SelectiveScrollingOrientation="Vertical"
    Foreground="{StaticResource GrayBrush}" 
    Background="{StaticResource DarkBlueBrush}"/>
      <telerik:GridViewNewRow x:Name="PART_AddNewRow" HorizontalAlignment="Left" IndentLevel="{TemplateBinding GroupCount}" telerik2:StyleManager.Theme="{StaticResource Theme}" Visibility="Collapsed" VerticalAlignment="Bottom"/>
      </StackPanel>
      <telerik:GridViewVirtualizingPanel x:Name="PART_GridViewVirtualizingPanel" Grid.Row="2"/>
      <StackPanel Grid.Row="3">
      <telerik:GridViewFooterRow x:Name="PART_FooterRow" IndentLevel="{TemplateBinding GroupCount}" telerik2:StyleManager.Theme="{StaticResource Theme}"/>
      </StackPanel>
      <telerik:ScrollPositionIndicator x:Name="PART_ScrollPositionIndicator" ContentTemplate="{TemplateBinding ScrollPositionIndicatorTemplate}" HorizontalAlignment="Right" IsHitTestVisible="False" Margin="0,0,28,0" Grid.Row="2" telerik2:StyleManager.Theme="{StaticResource Theme}" Visibility="{Binding IsScrolling, Converter={StaticResource BooleanToVisibilityConverter}, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"/>
      <Border x:Name="PART_FrozenColumnsPreview" Background="#33000000" HorizontalAlignment="Left" Grid.Row="1" Grid.RowSpan="3" Visibility="Collapsed" Width="6"/>
      <telerik:GridViewLoadingIndicator x:Name="PART_GridViewLoadingIndicator" telerik2:StyleManager.Theme="{StaticResource Theme}" Visibility="Collapsed"/>
      </Grid>
      </Border>
      </ControlTemplate>
      <SolidColorBrush x:Key="ControlBackground" Color="White"/>
      <SolidColorBrush x:Key="ControlOuterBorder" Color="#FF848484"/>
      <SolidColorBrush x:Key="ControlForeground" Color="Black"/>
      <SolidColorBrush x:Key="Item_AlternateBackground" Color="#FFF4F4F4"/>
      <SolidColorBrush x:Key="GridView_GridLinesItemBorder" Color="#FFCBCBCB"/>
      <LinearGradientBrush x:Key="GridView_GroupPanelBackground" EndPoint="0.5,1" StartPoint="0.5,0">
      <GradientStop Color="#FFDFDFDF" Offset="1"/>
      <GradientStop Color="#FFBABABA"/>
      </LinearGradientBrush>
      <SolidColorBrush x:Key="GridView_GroupPanelForeground" Color="Black"/>
      <Style x:Key="GridViewDataControlStyle1" TargetType="telerik:GridViewDataControl">
      <Setter Property="Template" Value="{StaticResource GridViewDataControlTemplate}"/>
      <Setter Property="Background" Value="{StaticResource ControlBackground}"/>
      <Setter Property="BorderBrush" Value="{StaticResource ControlOuterBorder}"/>
      <Setter Property="BorderThickness" Value="1"/>
      <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
      <Setter Property="VerticalContentAlignment" Value="Stretch"/>
      <Setter Property="Padding" Value="0"/>
      <Setter Property="Foreground" Value="{StaticResource ControlForeground}"/>
      <Setter Property="AlternateRowBackground" Value="{StaticResource Item_AlternateBackground}"/>
      <Setter Property="VerticalGridLinesBrush" Value="{StaticResource GridView_GridLinesItemBorder}"/>
      <Setter Property="HorizontalGridLinesBrush" Value="{StaticResource GridView_GridLinesItemBorder}"/>
      <Setter Property="GroupPanelBackground" Value="{StaticResource GridView_GroupPanelBackground}"/>
      <Setter Property="GroupPanelForeground" Value="{StaticResource GridView_GroupPanelForeground}"/>
      </Style>
     
     </UserControl.Resources>
     <Grid DataContext="{Binding Source={StaticResource DXEmployeesSampleDataSource}}">
    <telerik:GridViewDataControl ItemsSource="{Binding Mode=OneWay}" Style="{StaticResource GridViewDataControlStyle1}" Foreground="{StaticResource WhiteTextBrush}" Background="{StaticResource DarkBlueBrush}">
    <telerik:GridViewDataControl.Columns>
    <telerik:GridViewDataColumn  
    Header="LastName" 
    HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}">
    </telerik:GridViewDataColumn>
    <telerik:GridViewDataColumn Header="FirstName" 
    HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}"/>
    </telerik:GridViewDataControl.Columns>
    </telerik:GridViewDataControl>
    <telerik:GridViewHeaderCell 
    Content="GridViewHeaderCell" 
    HorizontalAlignment="Left" 
    VerticalAlignment="Top" Style="{StaticResource GridViewHeaderCellStyle1}" 
    />
      </Grid>
    </UserControl>


  2. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 22 Jul 2010 Link to this post

    Hello Wimpie Schoeman,

    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
    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
  3. DevCraft banner
  4. Wimpie Schoeman
    Wimpie Schoeman avatar
    7 posts
    Member since:
    Jun 2010

    Posted 22 Jul 2010 Link to this post

    Hi there

    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>

  5. Pavel Pavlov
    Admin
    Pavel Pavlov avatar
    2039 posts

    Posted 23 Jul 2010 Link to this post

    Hello Wimpie Schoeman,

    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
    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
  6. Wimpie Schoeman
    Wimpie Schoeman avatar
    7 posts
    Member since:
    Jun 2010

    Posted 26 Jul 2010 Link to this post

    Thanks for the reply.

    I am using Silverlight 4 and Telerik version 2010.1.603.1040.

    Kind regards
  7. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 29 Jul 2010 Link to this post

    Hello Wimpie Schoeman,

    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
    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
  8. Viet Dung
    Viet Dung avatar
    1 posts
    Member since:
    Jul 2010

    Posted 20 Sep 2010 Link to this post

    Thx so much :)
  9. Keerti
    Keerti avatar
    10 posts
    Member since:
    Jan 2011

    Posted 05 Apr 2011 Link to this post

    Hi Vanya,

    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

  10. Keerti
    Keerti avatar
    10 posts
    Member since:
    Jan 2011

    Posted 05 Apr 2011 Link to this post

    Hi Vanya,

    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
  11. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 06 Apr 2011 Link to this post

    Hello Keerti

     

    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.


    Greetings,
    Vanya Pavlova
    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
  12. Keerti
    Keerti avatar
    10 posts
    Member since:
    Jan 2011

    Posted 06 Apr 2011 Link to this post

    Hi Vanya,

    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
  13. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 06 Apr 2011 Link to this post

    Hello Keerti,


    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
    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
  14. JJ Loubser
    JJ Loubser avatar
    42 posts
    Member since:
    Jul 2009

    Posted 12 May 2011 Link to this post

     <SolidColorBrush x:Key="RadCellGridView_HeaderForeground" Color="Black" />

     <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?




  15. Ivan Ivanov
    Admin
    Ivan Ivanov avatar
    1128 posts

    Posted 12 May 2011 Link to this post

    Hi JJ Loubser,

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