Need to customize Grid Header height in WPF (Material Theme)

1 Answer 264 Views
GridView
Monica
Top achievements
Rank 1
Monica asked on 08 Oct 2022, 11:42 AM

Telerik Team,
In my project 
I have used material theme for the Telerik grid ( Xaml approach )and I want to adjust the height of header row. To achieve this If I Modify the height in common template, It will be applied to all the pages, Is there any way to modify the header height and header cell height specific to the page ? 

If so, please let me know how to change the height. Thanks in advance

 

1 Answer, 1 is accepted

Sort by
0
Martin Ivanov
Telerik team
answered on 12 Oct 2022, 09:03 AM

Hello Monica,

One way to achieve your requirement is to modify the ControlTemplate of RadGridView, as you already mentioned. To apply it only for the page you want, you can merge a ResourceDictionary with the custom template only in the Resources of the view where the template should be applied. For example, if the custom template is defined in a ResourceDictionary named "CustomGridViewStyles", you can merge it in the UserControl, the panel (like Grid) or the RadGridView resources. 

<UserControl.Resources>
    <ResourceDictionary Source="CustomGridViewStyles.xaml" />
</UserControl.Resources>

However, for your requirement it would be easier to use Styles targeting the GridViewHeaderCell and GridViewHeaderRow elements. For example:

<telerik:RadGridView Margin="5" GroupRenderMode="Flat">
	<telerik:RadGridView.Resources>
		<Style TargetType="telerik:GridViewHeaderCell">                    
			<Setter Property="MinHeight" Value="0"/>
		</Style>
	</telerik:RadGridView.Resources>
	<telerik:RadGridView.HeaderRowStyle>
		<Style TargetType="telerik:GridViewHeaderRow">
			<Setter Property="Height" Value="35" />
			<Setter Property="MinHeight" Value="0" />                    
		</Style>
	</telerik:RadGridView.HeaderRowStyle>
	<telerik:RadGridView.Columns>
		<telerik:GridViewDataColumn Header="Name" />
		<telerik:GridViewDataColumn Header="Established"/>
		<telerik:GridViewDataColumn Header="Stadium Capacity"/>
	</telerik:RadGridView.Columns>
</telerik:RadGridView>

I hope that helps.

Regards,
Martin Ivanov
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Monica
Top achievements
Rank 1
commented on 02 Nov 2022, 12:21 PM

@Martin Ivanov,

Sorry for the late reply, The solution is working for me. Thank you

Tags
GridView
Asked by
Monica
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
Share this question
or