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

Set Property HeaderCellStyle for GridViewDataColumn in App.xaml

4 Answers 339 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Vlad
Top achievements
Rank 1
Vlad asked on 11 Jun 2015, 11:25 AM

Hello. 

When I set property HeaderCellStyle to one control, the style is set.

 <telerik:RadGridView ColumnWidth="*" ItemsSource="{Binding PagedSource, ElementName=RadDataPager}">
     <telerik:RadGridView.Columns>
          <telerik:GridViewDataColumn Header="{Binding Source={StaticResource ResProvider}, Path=cLeng, Mode=OneWay}" 
                                                          DataMemberBinding="{Binding Length}"  HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}" /> -->
    </telerik:RadGridView.Columns>
</telerik:RadGridView>

But when i move this property to App.xaml file, it doesn't work

<Style TargetType="telerik:GridViewDataColumn">
     <Setter Property="HeaderCellStyle" Value="{StaticResource GridViewHeaderCellStyle1}"/>
</Style>

Can you show me the reason?

4 Answers, 1 is accepted

Sort by
0
Dimitrina
Telerik team
answered on 11 Jun 2015, 12:18 PM
Hi,

Would you please try applying an implicit Style targeting the GridViewHeaderCell element directly?
For example:
<Style TargetType="telerik:GridViewHeaderCell">
    <Setter Property="Background" Value="Red"/>
</Style>

That way it will be applied to all elements of type GridViewHeaderCell.

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
0
Vlad
Top achievements
Rank 1
answered on 11 Jun 2015, 12:59 PM

Dimitrina, thank you for your answer.

Your example works. But I want to switch off Over and Focus events. 

0
Dimitrina
Telerik team
answered on 11 Jun 2015, 01:26 PM
Hello,

You can consider editing the template of GridViewHeaderCell to remove specific visual states. You can follow this article on two different approaches on how to extract the ControlTemplates.

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
0
Vlad
Top achievements
Rank 1
answered on 12 Jun 2015, 09:02 AM

I have already had style in file GridViewDataColumn.Style.xaml.

 <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="Style/GridViewDataColumn.Style.xaml"/>
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>

So I want to set this style to all GridViewDataColumn in one place (in App.xaml). Like

<Style TargetType="telerik:GridViewDataColumn">
     <Setter Property="HeaderCellStyle" Value="{StaticResource GridViewHeaderCellStyle1}"/>
</Style>

But this doesn't work. Only works when I set property to each control. Like

<telerik:GridViewDataColumn DataMemberBinding="{Binding Length}"  HeaderCellStyle="{StaticResource GridViewHeaderCellStyle1}" />

Tags
GridView
Asked by
Vlad
Top achievements
Rank 1
Answers by
Dimitrina
Telerik team
Vlad
Top achievements
Rank 1
Share this question
or