I wanted to reduce the height of the header row but cannot figure out how. Setting the RowHeight property works only for the rows and not for the header row.
Is there a way to reduce the height of the header row?
Thanks,
Kumar
9 Answers, 1 is accepted
Indeed you are right - setting RadGridView's RowHeight property will affect only GridViewRows. If you want to change the Height of GridViewHeaderRow you may do this through defining a simple style targeted at GridViewHeaderRow, as shown below:
<
Style
TargetType
=
"telerik:GridViewHeaderRow"
>
<
Setter
Property
=
"MinHeight"
Value
=
"10"
/>
</
Style
>
You may also mark this style as an explicit one with the x:Key attribute and set it on a grid level through the HeaderRowStyle property.
Best wishes,
Vanya Pavlova
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>
Hi Vanya
I followed the method you provided but there seems to be another issue.
Implementing the styling seems to remove all other styling from my headers, leaving them blank but resized.
Has the functionality changed? Or is it perhaps because I am using implicit styles?
Hi Dawid,
This behavior could be a result of using NoXAML DLLs. Are you using one of our predefined themes? In such a scenario, custom implicit styles targeting our controls need to have BasedOn property set to the default style of the control. Otherwise, the implicit style will override the default one. You can read more about this in the Styling the Controls help article in our documentation. In your case, check the following code snippet.
<Style TargetType="telerik:GridViewHeaderRow" BasedOn="{StaticResource GridViewHeaderRowStyle}">
<Setter Property="MinHeight" Value="10"/>
</Style>
Regards,
Dinko
Progress Telerik
Hi Dinko
This solves the visibility issue, thank you. I am however still having an issue. Any value for the MinHeight property below 27 does not seem to affect the grid header height. I have also tried playing around with padding and margin but they do not seem to be the cause, do you have any suggestions to get past this?
Thanks
Dawid
Hello Dawid,
This happens because one of the elements in the GridViewHeaderRow template is having its MinHeight property set to 26. To avoid this limit you can subscribe to the RowLoaded event of RadGridView and set the MinHeight of this element in code. Here is an example in code:
private void RadGridView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
{
if (e.Row is GridViewHeaderRow)
{
e.Row.MinHeight = 10;
var headerCell = e.Row.ChildrenOfType<Grid>().FirstOrDefault(x => x.Name == "PART_HeaderCellGrid");
headerCell.MinHeight = 0;
}
}
I hope this helps.
Regards,
Martin Ivanov
Progress Telerik
Hi Martin
I tried this approach but i still don't get a reduced header height, could you perhaps provide a sample project as a demonstration?
Thanks in advance
Dawid
Hello Dawid,
I've attached my test project. I hope it helps.
Note that the project uses the Xaml version of the dlls.
Regards,
Martin Ivanov
Progress Telerik
Hi Martin
Thank you for the response. I am using NoXaml dll's, will it require a different solution?
Kind regards
Dawid
Hello Dawid,
No, the solution is the same, but the setup will be sightly different. You will need to reference also the Telerik theme dll and merge the corresponding resources as shown in the Setting a Theme article.
Regards,
Martin Ivanov
Progress Telerik