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

How to change title row background

5 Answers 344 Views
GridView
This is a migrated thread and some comments may be shown as answers.
zhiwei
Top achievements
Rank 1
zhiwei asked on 07 Mar 2011, 03:06 AM

Hello, I have two question about Grid View.

 

Q1. How to change background color of the title row? I’d tried to change the background color of some columns’ title, but the first column’s background and the border are still black.

 

Q2. I also don’t know how to change the background of the child table.

 

Thank you!

Zhiwei.

5 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 07 Mar 2011, 06:31 PM
Hi Zhiwei,

You will need to define a simple style or to edit the template of the GridViewHeaderRow and set the Background property to the desired color. Afterwards, using its Key attribute, you may set it explicitly in the RadGridView. 
Considering your second question, you have to change the background of the Border element around the PART_HierarchyChildPresenter within the style of the GridViewRow (please refer to the attached picture).


Greetings,
Vanya Pavlova
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
zhiwei
Top achievements
Rank 1
answered on 09 Mar 2011, 08:10 AM
Thank you for your reply, please forgive my less experience, I have another question, how to change the border color of the header data column,can it be setting in the template? If not , please tell me how to set it in the column definition.

Thank you very much!
0
Vanya Pavlova
Telerik team
answered on 15 Mar 2011, 05:07 PM
Hello Zhiwei,

 

In this case you have to style the GridViewHeaderCell elements in RadGridView. You may change their appearance either by creating a simple style targeted at GridViewHeaderCell or by editing its template.
This style can be applied to all columns using an implict style or by setting this style in the corresponding column:

Copy Code
<Grid x:Name="LayoutRoot" Background="White" DataContext="{Binding Source={StaticResource SampleDataSource}}">
        <Grid.Resources>
            <Style x:Key="style1" TargetType="telerik:GridViewHeaderCell">
        <Setter Property="Background" Value="Red"/>
        <Setter Property="BorderThickness" Value="0"/>
        </Style>
        </Grid.Resources>
       <telerik:RadGridView  Margin="40,24,88,72" ItemsSource="{Binding Collection}">
            <telerik:RadGridView.Columns>
                <telerik:GridViewDataColumn Header="EmployeeName" HeaderCellStyle="{StaticResource style1}" DataMemberBinding="{Binding Property3}"/>
                </telerik:RadGridView.Columns>
            </telerik:RadGridView>
    </Grid>


You may notice that this simple style changes only the outer border of GridViewHeaderCell, if you need to change its inner border you have to edit its template, this rule is valid for most RadGridView's parts.


Kind regards,
Vanya Pavlova
the Telerik team
Registration for Q1 2011 What’s New Webinar Week is now open. Mark your calendar for the week starting March 21st and book your seat for a walk through all the exciting stuff we ship with the new release!
0
zhiwei
Top achievements
Rank 1
answered on 21 Mar 2011, 04:11 AM
Hello telerik,

Could you show me an example of how to change header cell's inner border. Thank you very much!

Best regards!
0
Vanya Pavlova
Telerik team
answered on 22 Mar 2011, 09:14 AM
Hi zhiwei,

 
I would suggest you to review our online documentation that describes the template structure of different RadGridView's parts, please follow this link.

Also you may find attached sample project that demonstrates the approach above.

Greetings,
Vanya Pavlova
the Telerik team
Tags
GridView
Asked by
zhiwei
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
zhiwei
Top achievements
Rank 1
Share this question
or