We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to set Auto for HeaderRowHeight property?

Thread ID:





120695 Oct 5,2015 03:13 PM UTC Oct 6,2015 07:00 PM UTC WPF 1
Tags: SfDataGrid
Asked On October 5, 2015 03:13 PM UTC


I want to set Auto for HeaderRowHeight property of SfDataGrid.
Some of my headers contain long string and I want to wrap the text (I've written Template for this), but it isn't displayed because height of header row is too small.
I can set HeaderRowHeight property with some value, but I'm not so sure it will look appropriate in different DPI of screens etc. 

Sowndaiyan Paulpandi [Syncfusion]
Replied On October 6, 2015 07:00 PM UTC

Hi Daniel,

Thank you for contacting Syncfusion Support.

We have analyzed your query. You can achieved your requirement to increase the header row height by getting the Formatted text height and set that height to Header row height in Grid loaded event like below code example,

Code Example[C#]:

datagrid_Loaded(object sender, RoutedEventArgs e)
            var row = this.datagrid.GetRowGenerator().Items[0];
            FormattedText formattedtext = null;
            var visibleColumns = row.GetType().GetProperty("VisibleColumns", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).GetValue(row, null) as List<DataColumnBase>;
            foreach (var item in visibleColumns)
                double maxheight = 0.0;
                string[] columnNames = item.GridColumn.HeaderText.Split(' ');
                foreach (var columnName in columnNames)
                    formattedtext = new FormattedText(columnName,
                                System.Globalization.CultureInfo.CurrentCulture, datagrid.FlowDirection,
                                new Typeface(datagrid.FontFamily, datagrid.FontStyle, FontWeights.Normal,
                                    new FontStretch()), 14, Brushes.Black);
                    maxheight += formattedtext.Height;
                if (datagrid.HeaderRowHeight < maxheight)
                    datagrid.HeaderRowHeight = maxheight;


We have prepared a sample based on your requirement and you can download it from the following location.

Sample Location:

Please let us know if you require further assistance on this.



This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

or the page will be automatically redirected to sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon