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

How to modified text 's color of header

3 Answers 220 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Totti
Top achievements
Rank 1
Totti asked on 27 Sep 2010, 11:24 AM
I have telerik:RadGridView  control, I want to set text 's color of header for Grid, I tried some ways as implement behind code, set property in XAML file, but I can't set color for text of Grid's header. (I'm using the latest ver of SilverLight 4.0 )
- case of XAML file:

 <Grid Grid.Row="3" Grid.Column="1" Margin="15,15,15,12" Grid.RowSpan="2">
                            <Grid.Resources>
                                <Style x:Key="GridViewHeaderRowStyle" TargetType="telerik:GridViewHeaderRow">
                                    <Setter Property="Template" Value="{StaticResource GridViewHeaderRowTemplate}"/>
                                    <Setter Property="Background" Value="#CC0010"/>
                                    <Setter Property="Foreground" Value="White"/>
                                   
                                </Style>
                            </Grid.Resources>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="0.041*"/>
                                <ColumnDefinition Width="0.145*"/>
                                <ColumnDefinition Width="0.814*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="auto"/>
                                <RowDefinition Height="30"/>
                            </Grid.RowDefinitions>
                            <telerik:RadGridView Grid.Row="0" AutoGenerateColumns="False" Name="grdRDFMatrix"
                                ColumnWidth="*" GridLinesVisibility="Horizontal"
                                ScrollViewer.VerticalScrollBarVisibility="Auto"                                
                                IsReadOnly="True" ItemsSource="{Binding DataList, Mode=TwoWay}"                                      
                                CanUserInsertRows="True"  
                                          
                                ShowGroupPanel="False"  Grid.ColumnSpan="3"   telerikGridViewFilter:CustomFilterRow.IsEnabled="True"
                                                                         >
                                <telerik:RadGridView.Columns>
                                    <telerik:GridViewDataColumn Header="Rate" UniqueName="Rate" Width="*"  HeaderCellStyle="{StaticResource GridViewHeaderRowStyle}" />
                                    <telerik:GridViewDataColumn Header="Destination" UniqueName="Destination" Width="*" HeaderCellStyle="{StaticResource GridViewHeaderRowStyle}"/>
                                    <telerik:GridViewDataColumn Header="Format" UniqueName="Format" Width="*" HeaderCellStyle="{StaticResource GridViewHeaderRowStyle}" />
                                    <telerik:GridViewDataColumn Header="Fee Table" UniqueName="FeeTable" Width="*" HeaderCellStyle="{StaticResource GridViewHeaderRowStyle}"/>
                                </telerik:RadGridView.Columns>
                            </telerik:RadGridView>
                            <telerik:RadDataPager Grid.Row="1" Template="{StaticResource RadDataPagerTemplate}"
                                   x:Name="radDataPager1"
                                   PageSize="{Binding Value, ElementName=Pagesize,Mode=TwoWay}"
                                   Source="{Binding Items, ElementName=grdRDFMatrix}"
                                   DisplayMode="All"
                                   AutoEllipsisMode="Both"
                                   NumericButtonCount="5"
                                   IsTotalItemCountFixed="True"  Grid.ColumnSpan="3" />
                            <StackPanel Orientation="Horizontal" Grid.Row="1" HorizontalAlignment="Center" VerticalAlignment="Center" Grid.Column="2" Width="200">
                                <TextBlock Text="Page Size" VerticalAlignment="Center" />
                                <telerik:RadMaskedTextBox MaskType="Numeric" Mask="d3" Name="Pagesize" Height="23" Width="40" Margin="7,0,0,0" Value="10" TextAlignment="Center"/>
                            </StackPanel>
                            <Grid Grid.Row="2" Grid.ColumnSpan="3" >
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                    <ColumnDefinition Width="*"/>
                                </Grid.ColumnDefinitions>
                                <Button Grid.Column="0" Content="Save" Width="66" Height="25" VerticalAlignment="Center" Command="{Binding SaveRDFCommand}" CommandParameter="InsertRDFMatrix" HorizontalAlignment="Left"/>
                                <Button Content="Associate" Height="25" Grid.Column="1" HorizontalAlignment="Center" Width="83" VerticalAlignment="Center" Click="btnAssociate_Click"/>
                                <StackPanel Grid.Column="2" Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,0,5,0">
                                    <HyperlinkButton Content="Import" Grid.Column="1" FontSize="12"  Name="lnkImport" VerticalAlignment="Center" Grid.Row="2" />
                                    <TextBlock Grid.Column="1"  Text="/" VerticalAlignment="Center" FontSize="12" Margin="5,0,5,0"/>
                                    <HyperlinkButton Content="Export" Grid.Column="1"  Name="lnkExport" FontSize="12" VerticalAlignment="Center"/>
                                </StackPanel>
                            </Grid>
                        </Grid>
                    </Border>

                    <Button Click="btnNextFT_Click" x:Name="BtBottomRight" Content="" Grid.Column="1" Grid.Row="4" HorizontalAlignment="Right" VerticalAlignment="Center"  Style="{StaticResource ArrowButton}"  Width="28" Grid.ColumnSpan="2" Margin="0,130,97,80">
                        <Button.RenderTransform>
                            <CompositeTransform Rotation="90"></CompositeTransform>
                        </Button.RenderTransform>
                    </Button>
                </Grid>
            </telerik:RadBusyIndicator>
        </Grid>
- Case of code hehind:

 this.grdRDFMatrix.DataLoaded += new System.EventHandler<System.EventArgs>(grdRDFMatrix_DataLoaded);
 private void grdRDFMatrix_DataLoaded(object sender, System.EventArgs e)
        {
            foreach (var col in this.grdRDFMatrix.Columns)
            {
                col.HeaderCellStyle = (Style) this.Resources["GridViewHeaderRowStyle"];
            }
        }

-------

More: I changed successfully with background property but impossible with Foreground.
It's better, if you have simple example about change text 's color of header Grid using Foreground property.

3 Answers, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 27 Sep 2010, 12:45 PM
Hello Totti,

You can try to set a style targeting the GridViewHeaderCell:

<Style TargetType="telerik:GridViewHeaderCell">
    <Setter Property="Foreground" Value="HotPink"/>
    <Setter Property="Background" Value="Azure" />         
</Style>
 

Regards,
Maya
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
0
Claudio
Top achievements
Rank 1
answered on 11 Aug 2013, 11:03 PM
Is there a way to control a grid header foreground and background individually? Meaning not change all the column headers to the same color or same text? i'm using GridViewTextBoxColumn in WinForms version 2012.2.912.40
0
Maya
Telerik team
answered on 12 Aug 2013, 07:26 AM
Hi Claudio,

Will it be possible to post your question on the related WinForms telerik forum ?
Thank you in advance.  

Regards,
Maya
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for SILVERLIGHT.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Totti
Top achievements
Rank 1
Answers by
Maya
Telerik team
Claudio
Top achievements
Rank 1
Share this question
or