Skip to content

Latest commit

 

History

14 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

How to Change the Font Size for Header With ColumnSizer as SizeToHeader in WPF DataGrid?

This sample show cases how to change the fontsize for header with ColumnSizer as SizeToHeader in WPF DataGrid (SfDataGrid).

The header text width is calculated with static font size in DataGrid and you can change the header font size using HeaderStyle property. You can achieve this by overriding GetFormattedText method in SfDataGrid.ColumnSizer class.

C#

public class GridColumnSizerExt : GridColumnSizer
{
    public GridColumnSizerExt(SfDataGrid dataGrid) : base(dataGrid)
    {

    }

    protected override FormattedText GetFormattedText(GridColumn column, object record, string displayText)
    {
        var formattedText = base.GetFormattedText(column, record, displayText);

        if (record == null)
        {
            formattedText.SetFontSize(16);
        }
        return formattedText;
    }
}

Changing the font size of the header with column sizer as SizeToHeader

Requirements to run the demo

Visual Studio 2015 and above versions

About

How to change the fontsize for header with ColumnSizer as SizeToHeader in WPF DataGrid (SfDataGrid) ?

Topics

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages