Articles in this section
Category / Section

How to customize the height of Stacked Header Row in SfDataGrid?

1 min read

SfDataGrid allows you to have additional unbound header rows, known as Stacked Header Rows that span across Grid Columns. You can group two or more columns under each of the Stacked Header. A Stacked Header Row is viewed as a set of Stacked Columns, where each Stacked Column contains a number of Child Columns. By default, the Stacked Header Row’s height is constantly maintained as 24 as shown in the following screenshot.

 

C:\Users\Adithi\AppData\Roaming\Skype\My Skype Received Files\modified.png

Figure 1: Default row height of the Stacked Header Row

You can customize the height of Stacked Header Row by accessing the RowHeight property of the Visual Container. You can access the Visual Container by using the GetVisualContainer() extension method that exists in the Syncfusion.UI.Xaml.Grid.Helpers namespace in SfDataGrid.

Calculated here is the count of the StackedHeaderRows and RowHeight is applied to each row of the Stacked Header.

C#

//Namespace to access GetVisualContainer() extension method 
using Syncfusion.UI.Xaml.Grid.Helpers;
void SfDataGrid_Loaded(object sender, RoutedEventArgs e)
        {
            //Get the VisualContainer
            var visualcontainer = SfDataGrid.GetVisualContainer();                     
            //Stacked Header Row count is calculated here
            int count = SfDataGrid.StackedHeaderRows.Count;
            for (int i = 0; i < count; i++)
            {
                //The Stacked Header Row Height is customized by setting the value as 50.                
                visualcontainer.RowHeights[i] = 50;
            }
            //We have called InvalidateMeasure() to  Invalidates the measurement state  for the VisualContainer. 
            visualcontainer.InvalidateMeasure();
        }

The above RowHeight value changes are set to Stacked Header Row as shown in the following screenshot.

 

C:\Users\Adithi\AppData\Roaming\Skype\My Skype Received Files\modif.png

Figure 2: Customized Row Height

 

Sample Links:

WPF

WRT

UWP

Conclusion

I hope you enjoyed learning about how to customize the height of Stacked Header Row in SfDataGrid.

You can refer to our WinRT DataGrid featuretour page to know about its other groundbreaking feature representations and documentation, and how to quickly get started for configuration specifications. You can also explore our WinRT DataGrid example to understand how to create and manipulate data.

For current customers, you can check out our components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our other controls.

If you have any queries or require clarifications, please let us know in the comments section below. You can also contact us through our support forumsDirect-Trac, or feedback portal. We are always happy to assist you!

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment
Access denied
Access denied