We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

SfDataGrid column width AutoWithLastColumnFill to specific column

Thread ID:





120567 Sep 25,2015 04:41 PM UTC Oct 1,2015 02:32 AM UTC WPF 3
Tags: SfDataGrid
George Sterg
Asked On September 25, 2015 04:41 PM UTC

Hello, I'm using the SfDataGrid and i want the SfDataGrid to fill the width of the window whenever I'm resizing the window. I'm using the ColumnSizer="AutoWithLastColumnFill"  to do that, but I want a specific column to have that ability and not the last one. In my case is the second column (In other words, when I'm resizing the window i want the second column width to change). I tried setting the SfDataGrid.ColumnSizer="Auto" and the column i want to ColumnSizer="AutoWithLastColumnFill" but it does not work.  Any help?



George Sterg
Replied On September 25, 2015 05:45 PM UTC

I' made a workaround and I'm sharing it:
 Used a MultiBinding Converter and added the Window Width and the rest of the columns ActualWidth as parameters

                            <MultiBinding Converter="{StaticResource AutoFillColumnWidthConverter}">
                                <Binding Path="Width" ElementName="Window"  FallbackValue="0"/>
                                <Binding Path="ActualWidth" ElementName="Column1" FallbackValue="0"/>
                                <Binding Path="ActualWidth" ElementName="Column3" FallbackValue="0"/>
                                <Binding Path="ActualWidth" ElementName="Column4" FallbackValue="0"/>
                                <Binding Path="ActualWidth" ElementName="LastColumn" FallbackValue="0"/>

 public class AutoFillColumnWidthConverter : IMultiValueConverter
        public double WindowWidth { get; set; }

        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
            WindowWidth = (double)values[0];

            double DataGridWidth = 0;
            List<object> list = values.ToList();

            foreach (var value in list)
                double width = System.Convert.ToDouble(value);
                if (!double.IsNaN(width))
                    DataGridWidth += width;
            return WindowWidth  - DataGridWidth;

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
            throw new NotImplementedException();

Jai Ganesh S [Syncfusion]
Replied On September 28, 2015 12:51 PM UTC

Hi George,

Thank you for using Syncfusion Products.

We have analyzed your query. We cannot achieve your requirement directly to adjust the specific column width like AutoWithLastColumnFill behavior for last column. Currently we are working on the sample to achieve your requirement by overriding the GridColumnSizer and we will let you know the status on or before September 30, 2015.

Please let us know if you have any query.

Thank you,

Jai Ganesh S

Jai Ganesh S [Syncfusion]
Replied On October 1, 2015 02:32 AM UTC

Hi George,

You can achieve your requirement to “Adjust the specific column width like AutoWithLastColumnFill behavior for last column” through work around. We have prepared the sample based on this and you can download the sample from the below location,

Sample: http://www.syncfusion.com/downloads/support/directtrac/144750/ze/SfGridDemo-346634687

In the above sample, we have adjusted the width for EmployeeArea column.

Please let us know if you have any other query.


Jai Ganesh S


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon