dataGrid.GridColumnSizer.Refresh() throws null exception

Hi,


So i have an event that fires from my VM and this is handled in my .xaml.cs code behind file in my view.

Handler is below. I put the 2 if statements to test if they were the reasons for the error but they are not.

The code still runs and throws exception on dataGrid.GridColumnSizer.Refresh();

I have confirmed dataGrid.GridColumnSizer is not null (prior line would have otherwise thrown excpetion).

What is internally throwing the null exception? How can i check?


private void Vm_UiRefreshRequest()

{

    if (!dataGrid.IsLoaded)

    { return; }


    if (dataGrid.ItemsSource is ICollection coll && coll.Count > 0)

    {

        //has rows

        dataGrid.GridColumnSizer.ResetAutoCalculationforAllColumns();

        dataGrid.GridColumnSizer.Refresh();

    }

}


1 Reply

RM Rabina Murugan Syncfusion Team August 25, 2025 02:40 PM UTC

Hi Lorenzo,

 

We have investigated the reported scenario. However we are unable to replicate the reported NullReferenceException when invoking GridColumnSizer's Refresh method. We have attached the tested sample demo with the provided codes.

 

To investigate further, kindly share the following details: 

 

  • Please replicate the issue in the attached demo.
  • Any customizations made related to columnsizer.

 

Find the sample demo in the attachment.

 

This information will help us analyze the problem more effectively.

 

Regards,

Rabina M


Attachment: SfDataGrid_Demo_c21c7444.zip

Loader.
Up arrow icon