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

Always Fill?

Thread ID:

Created:

Updated:

Platform:

Replies:

125697 Sep 4,2016 01:56 AM UTC Sep 5,2016 10:28 AM UTC UWP 2
loading
Tags: SfDataGrid
Bradley Plett
Asked On September 4, 2016 01:56 AM UTC

I am using an SfDataGrid in a UWP application.  I would like the grid always to fill, horizontally, a cell in a parent grid (not a data grid - just a Windows grid).  I have five columns, which can all be the same width.  (I'd prefer to set the widths proportionally using something like "*", "2*", etc., but that's less important.)  I would like to set a minimum width on the grid columns and, if the space is too narrow a scroll bar would appear and if it's too wide the columns stretch to fill the space.  Despite my many attempts and many combinations/permutations, I have been unable to make this happen.  Help would be much appreciated.

Thanks!
Brad.

Antony Raj M [Syncfusion]
Replied On September 5, 2016 10:24 AM UTC

Hi Bradley, 

We have analyzed your query and you can achieve your requirement by overriding the Refresh method in GridColumnSizer like below code example. 

 
public MainPage() 
{ 
    this.InitializeComponent(); 
    this.dataGrid.GridColumnSizer = new GridColumnSizerExt(this.dataGrid); 
} 
 
 
public class GridColumnSizerExt:GridColumnSizer 
{ 
    public GridColumnSizerExt(SfDataGrid dataGrid) : base(dataGrid) { } 
 
    protected override void Refresh(double AvailableWidth) 
    { 
        base.Refresh(AvailableWidth); 
        var visualContainer = this.DataGrid.GetVisualContainer(); 
        if(AvailableWidth > visualContainer.ScrollColumns.ViewSize) 
        { 
            DataGrid.ColumnSizer = GridLengthUnitType.Star; 
            DataGrid.GridColumnSizer.Refresh(); 
        } 
    } 
} 

We also prepared the same and you can download the sample from below location. 

Sample: 

Please refer the below link to know more about column sizer. 

Regards, 
Antony Raj 


Antony Raj M [Syncfusion]
Replied On September 5, 2016 10:28 AM UTC

Hi Bradley, 

You can download the sample for previous update from below link. 


Regards, 
Antony Raj 


CONFIRMATION

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.

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

;