Change Height of GridViewColumnGroup within a Style for RadGridView

1 Answer 205 Views
GridView
Damian
Top achievements
Rank 1
Damian asked on 16 May 2023, 11:37 AM

Hi 

Currently I am trying to change the height of the GridViewColumnGroup from a global style,

Right now the height is being altered but its not quite I am looking for.

This is the current result Where the header is no longer vertically aligned 

These are the global style tags

The desired result is for the Height value to be changed via a data trigger and the group header to be aligned vertically in the center

Any assistance here would be appreciated 

1 Answer, 1 is accepted

Sort by
1
Accepted
Stenly
Telerik team
answered on 19 May 2023, 10:16 AM

Hello Damian,

To change the height of the column groups, the Style that targets the CommonColumnHeader class could be extended. A new Style with TargetType="Grid" could be defined in its Resources collection, and you could set the Height to the desired value.

The following code snippet shows what I have in mind:

<Style TargetType="telerik:CommonColumnHeader" BasedOn="{StaticResource CommonColumnHeaderStyle}">
    <Style.Resources>
        <Style TargetType="Grid">
            <Setter Property="Height" Value="60"/>
        </Style>
    </Style.Resources>
</Style>

The produced result is as follows:

The above code snippet could be extended to include a trigger.

Regarding the second question, looking at the shared images, it seems that the text should be aligned to the center. Please correct me if I am wrong, however, if this is the case, to achieve this, you could set the HorizontalContentAlignment property of the CommonColumnHeader to Center.

<Style TargetType="telerik:CommonColumnHeader" BasedOn="{StaticResource CommonColumnHeaderStyle}">
    <Setter Property="HorizontalContentAlignment" Value="Center"/>
</Style>

I hope the provided information will be of help to you.

Regards,
Stenly
Progress Telerik

Love the Telerik and Kendo UI products and believe more people should try them? Invite a fellow developer to become a Progress customer and each of you can get a $50 Amazon gift voucher.

Damian
Top achievements
Rank 1
commented on 22 May 2023, 02:42 PM

Hi Stenly 

Thank you for your response , so your solution works when making the grid header larger, but in the scenario of making the headers smaller we end up with the same issue. I've attached a sample project that has replicated the issue, I hope it shows our intentions slightly clearer. 

Any help will be appreciated, Thank you in advance 

Damian

Stenly
Telerik team
commented on 25 May 2023, 11:00 AM

Hello Damian,

To prevent this, the style of the CommonHeaderPresenter that was suggested in my initial reply could be extended. More specifically, to add an additional style that will target the GridViewColumnGroupRow element and its MinHeight and Height properties could be set.

The GridViewColumnGroupRow element is present in the following namespace:

xmlns:telerikGridView="clr-namespace:Telerik.Windows.Controls.GridView;assembly=Telerik.Windows.Controls.GridView"

The following code snippet shows this suggestion's implementation using the code from the MainView.xaml (from the sample project that you have provided):

<Style TargetType="telerik:CommonHeaderPresenter" BasedOn="{StaticResource {x:Type telerik:CommonHeaderPresenter}}">
    <Style.Resources>
        <Style TargetType="Grid">
            <Setter Property="Height" Value="24"/>
            <Style.Resources>
                <Style TargetType="telerikGridView:GridViewColumnGroupRow" BasedOn="{StaticResource GridViewColumnGroupRowStyle}">
                    <Setter Property="MinHeight" Value="24"/>
                    <Setter Property="Height" Value="24"/>
                </Style>
            </Style.Resources>
        </Style>
    </Style.Resources>
    <Setter Property="HorizontalContentAlignment" Value="Center"></Setter>
    <Setter Property="FontSize" Value="10"></Setter>
<Setter Property="MinHeight" Value="24"></Setter>

The produced result is as follows:

Could you give this suggestion a try?

Damian
Top achievements
Rank 1
commented on 25 May 2023, 11:24 AM

You're an absolute legend Stenly, this has worked like a charm , thank you so much :) 
Tags
GridView
Asked by
Damian
Top achievements
Rank 1
Answers by
Stenly
Telerik team
Share this question
or