WPF Data Grid and TreeList - Automatic Best Fit

WPF Team Blog
14 May 2020

Our WPF Data Grid and TreeList v20.1 can now automatically and dynamically resize columns during scroll and edit operations.

To demonstrate this feature, we recently published the following YouTube video.

Video Script: WPF Data Grid and WPF TreeList v20.1 - Dynamic Column Resizing

Enable Automatic Best Fit

To activate this new WPF Grid and TreeList option, simply set the appropriate column's Width property to Auto.

<dxg:GridControl.Columns>
    <dxg:GridColumn FieldName="FullName" Width="3*"/>
    <dxg:GridColumn FieldName="BirthDate" Width="2*"/>
    <dxg:GridColumn FieldName="JobTitle" Width="Auto" AllowResizing="False"/>
    <dxg:GridColumn FieldName="Phone" Width="2*"/>
</dxg:GridControl.Columns>

Best Fit During Source Change

We also added a BestFitModeOnSourceChange option. This allows our WPF Data Grid or TreeList to calculate the optimal width for all columns when the ItemsSource changes.

<dxg:GridControl Name="grid">
	<dxg:GridControl.View>
		<dxg:TableView Name="view" BestFitModeOnSourceChange="VisibleRows"/>
	</dxg:GridControl.View>
</dxg:GridControl>

Feedback

As always, we welcome your thoughts/opinions. Please post a comment below and let us know what you think about Automatic Best Fit.

Showcase Your Apps on DevExpress.com

Highlight your business app and share your development experiences with the DevExpress community. To include your app in our upcoming App Showcase, please forward an application screenshot to clientservices@devexpress.com and tell us which DevExpress products you currently use within your organization.
1 comment(s)
Andrew Tinkler
Andrew Tinkler
Keep up the good work!
15 May 2020

Please login or register to post comments.