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

Foreground styling of GroupHeaderRow

2 Answers 389 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Loic
Top achievements
Rank 1
Loic asked on 14 Jul 2014, 06:34 AM
Hello,

I am trying to set the color of the text in the GroupHeaderRow of my gridview. 
Both the title of the group (value of the column grouped) and the text of the aggregate functions.

When I use the office black theme, everything is in black and when I use the windows 8 theme, the aggregate function text is in blue.

I use a GroupRowStyleSelector :

<cstyle:ReconReportStyle x:Key="styleGroupHeaderRow">
            <cstyle:ReconReportStyle.UnmatchedStyle>
                <Style TargetType="telerik:GroupHeaderRow">
                    <Setter Property="Background" Value="Red"/>
                    <Setter Property="Foreground" Value="Pink"/>                     <!--  this setter does not change anything-->
                </Style>....


<telerik:RadGridView ...
GroupRenderMode="Flat"
GroupRowStyleSelector="{StaticResource styleGroupHeaderRow}"
</....>


 What should I do ?








2 Answers, 1 is accepted

Sort by
0
Accepted
Boris
Telerik team
answered on 14 Jul 2014, 02:40 PM
Hello Loic,

The easiest way to set the Foreground color of the GroupHeaderRow is to use the GroupHeaderTemplate property of the GridView. 

<telerik:RadGridView.GroupHeaderTemplate>
        <DataTemplate>
            <StackPanel Orientation="Horizontal">
                <TextBlock Text="{Binding Header}" Foreground="Yellow"/>
            </StackPanel>
        </DataTemplate>
</telerik:RadGridView.GroupHeaderTemplate>

In addition, to set the Background property of the GroupHeaderRow / GridViewGroupRow(depending on the GroupRenderMode), you can use a style.

GroupRenderMode="Flat":

<Style TargetType="telerik:GroupHeaderRow" BasedOn="{StaticResource GroupHeaderRowStyle}">
            <Setter Property="Background" Value="Red"/>
</Style>
    

GroupRenderMode="Nested":

<Style TargetType="telerik:GridViewGroupRow" BasedOn="{StaticResource GridViewGroupRowStyle}">
            <Setter Property="Background" Value="Red" />
</Style>

As for the aggregate functions, you can edit their ControlTemplate with x:Key="GridViewAggregateResultCellTemplate" directly in the Telerik.Windows.Controls.GridView.xaml file or through style. All you need to do is set the Foreground property of the two TextBlocks. For your conveyance I have implemented the second approach:

<Style TargetType="telerik:GridViewAggregateResultCell">
            <Setter Property="Template">
                <Setter.Value>
 
                    <ControlTemplate TargetType="telerik:GridViewAggregateResultCell">
                        <StackPanel Margin="{TemplateBinding Padding}"
                                    HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                    VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                    Background="{TemplateBinding Background}"
                                    Orientation="Horizontal">
                            <TextBlock Margin="10 0 0 0"
                                       VerticalAlignment="Center"
                                       Foreground="Yellow"
                                       Text="{Binding Caption}"
                                       TextAlignment="Right" />
                            <TextBlock Margin="3 0"
                                       VerticalAlignment="Center"
                                       Foreground="Yellow"
                                       Text="{Binding FormattedValue}"
                                       TextAlignment="Right" />
                        </StackPanel>
                    </ControlTemplate>
 
                </Setter.Value>
            </Setter>
        </Style>

I hope this helps.

Regards,
Boris Penev
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
0
Loic
Top achievements
Rank 1
answered on 15 Jul 2014, 01:31 AM
Thank you, it is working.
Tags
GridView
Asked by
Loic
Top achievements
Rank 1
Answers by
Boris
Telerik team
Loic
Top achievements
Rank 1
Share this question
or