How to set MinimumWidth to all columns of SfDataGrid of an application?

Hi I'd like to set a fixed minimum width to all columns of my application's sfDataGrid.

I've tried to define a global style like this in the application resource file.

  <Style TargetType="Syncfusion:GridColumn" x:Key="GridSizeColumn">
                <Setter Property="MinimumWidth" Value="10"></Setter>
            </Style>

But it doesn't work since the xaml compiler says that MinimumWidth is not a DependencyProperty.
Have you any idea how to set this property globally for all GridColumns instead of set it manually to every column in every sfDatagrid ?


2 Replies

SI Silvio October 16, 2018 09:48 AM UTC

Can anyone help me ?


DY Deivaselvan Y Syncfusion Team October 17, 2018 06:25 AM UTC

Hi Silvio,

Thank you for contacting Syncfusion support.

We do not have a direct API in SfDataGrid class to set MinimumWidth and Width for entire columns in the grid. However, you can achieve your requirement with the help of defining the attached property for DataGrid and set each column with that value in Loaded event and AutoGeneratingColumn event in the grid. Please refer the demo application which illustrate the same from the below link and let us know if this helps you.
http://www.syncfusion.com/downloads/support/forum/140061/ze/SfDataGridDemo-1349264697.zip

Regards,
Deivaselvan 


Loader.
Up arrow icon