Set Property HeaderCellStyle for GridViewDataColumn in App.xaml

5 posts, 0 answers
  1. Vlad
    Vlad avatar
    6 posts
    Member since:
    Jan 2014

    Posted 11 Jun 2015 Link to this post

    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?

  2. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 11 Jun 2015 Link to this post

    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
  3. DevCraft banner
  4. Vlad
    Vlad avatar
    6 posts
    Member since:
    Jan 2014

    Posted 11 Jun 2015 in reply to Dimitrina Link to this post

    Dimitrina, thank you for your answer.

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

  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 11 Jun 2015 Link to this post

    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
  6. Vlad
    Vlad avatar
    6 posts
    Member since:
    Jan 2014

    Posted 12 Jun 2015 in reply to Dimitrina Link to this post

    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}" />

Back to Top
DevCraft banner