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

Overwriting the GroupHeaderRowToggleButton style

3 Answers 190 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bogdan
Top achievements
Rank 1
Bogdan asked on 13 Nov 2017, 12:17 PM

Hi.

I am using Grouping with GroupRenderMode set to Flat and ColumnAggregatesAlignment set to NextToGroupKey.

My problem is that as long as i try i cannot overwrite the ToggleButton style in order to link the foreground to a resource.

Below is what i believe that is the style of the toggle button. Whatever i do, nothing works.

 <Style BasedOn="{StaticResource GroupHeaderRowToggleButtonStyle}" TargetType="{x:Type ToggleButton}">
                <Setter Property="Control.Template" Value="{StaticResource GroupHeaderRowToggleButtonTemplateCUSTOM}"/>
                <Setter Property="Control.HorizontalContentAlignment" Value="Left"/>
                <Setter Property="Control.VerticalContentAlignment" Value="Center"/>
                <Setter Property="Control.Padding" Value="9 0 0 0"/>
</Style>

3 Answers, 1 is accepted

Sort by
0
Accepted
Martin
Telerik team
answered on 16 Nov 2017, 08:24 AM
Hello,

The toggle button that holds the header has a static resource reference to the GridViewGroupToggleButtonStyle, so in the case you are trying to set it implicitly, it would now work. You could extract the template and modify it there. However, not that there are a lot of specific things in the GroupHeaderRow, so I would advice on changing as little as possible and keep any existing bindings to make sure everything would work properly after that.

In your specific case - if you aim to change only the foreground of the header, you could modify the GroupHeaderTemplate of the GroupHeaderRow. I could guess you are using the Office2013 theme. In it the data template used is:
<DataTemplate x:Key="GroupHeaderRowHeaderTemplate">
    <ContentControl Foreground="{telerik:Office2013Resource ResourceKey=InvertedBrush}" FontWeight="Bold" FontSize="{telerik:Office2013Resource ResourceKey=FontSizeS}" FontFamily="{telerik:Office2013Resource ResourceKey=FontFamily}" Content="{Binding Header}" />
</DataTemplate>
 
so you could modify it if you like and pass it to the whole row (grid is the namespace Telerik.Windows.Controls.GridView ) :
<Style BasedOn="{StaticResource GroupHeaderRowStyle}" TargetType="grid:GroupHeaderRow">
    <Setter Property="GroupHeaderTemplate" Value="{StaticResource GroupHeaderRowHeaderTemplate}" />
</Style>

If you are using any other theme, this data template could be found just before the GroupHeaderRowToggleButtonStyle in the Telerik.Windows.Controls.GridView.xaml for the chosen theme. The required part of the data template is <ContentPresenter Content="{Binding Header}" /> .

Regards,
Martin
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
0
Bogdan
Top achievements
Rank 1
answered on 16 Nov 2017, 10:33 AM

Hello.

Thank you for your quick reply.

Somehow i find the fact of the toggle buttons foreground not taking the template foreground kind of annoying. 

I managed to fix the issue by completely overwriting the GroupHeaderRowHeaderTemplate as you also implied, but it's 60 lines of code for just a foreground.

In any case, thank you for your reply.

0
Martin
Telerik team
answered on 21 Nov 2017, 09:55 AM
Hello,

You can only change the content template that targets the header button, named GroupHeaderTemplate as mentioned previously, which would save the unnecessary extracting of the whole group row template. I think technically the foreground of the header button is bound to the template, but is overwritten by the content template, which has a set foreground by default.

Regards,
Martin
Progress Telerik
Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Tags
GridView
Asked by
Bogdan
Top achievements
Rank 1
Answers by
Martin
Telerik team
Bogdan
Top achievements
Rank 1
Share this question
or