Category / Section
How to change the ColumnSizer for the Nested grid in WPF ?
1 min read
When you change the ColumnSizer of DataGrid, it is not applied to the DetailsView DataGrid. You can change the DetailsView DataGrid ColumnSizer directly by setting the GridViewDefinition.DataGrid.ColumnSizer as in the following code example.
XAML
<syncfusion:SfDataGrid x:Name="dataGrid"> <syncfusion:SfDataGrid.DetailsViewDefinition> <syncfusion:GridViewDefinition RelationalColumn="OrderDetails"> <syncfusion:GridViewDefinition.DataGrid> <syncfusion:SfDataGrid x:Name="FirstDetailsViewGrid" ColumnSizer="SizeToCells"> <syncfusion:SfDataGrid.Columns> <syncfusion:GridTextColumn MappingName="OrderID" /> <syncfusion:GridTextColumn MappingName="ProductID" TextAlignment="Right" /> <syncfusion:GridTextColumn HeaderText="Unit Price" MappingName="UnitPrice" TextAlignment="Right" /> <syncfusion:GridTextColumn MappingName="Quantity" TextAlignment="Right" /> <syncfusion:GridTextColumn MappingName="Discount" TextAlignment="Right" /> <syncfusion:GridTextColumn MappingName="CustomerID" /> <syncfusion:GridDateTimeColumn HeaderText="Order Date" MappingName="OrderDate" TextAlignment="Right" /> </syncfusion:SfDataGrid.Columns> </syncfusion:SfDataGrid> </syncfusion:GridViewDefinition.DataGrid> </syncfusion:GridViewDefinition> </syncfusion:SfDataGrid.DetailsViewDefinition> </syncfusion:SfDataGrid>