Home > DeveloperSection > Forums > WPF DataGrid Column Width
Ashish Pandey

Total Post:128

Points:898
Posted on    September-03-2013 5:00 AM

 WPF WPF 
Ratings:


 1 Reply(s)
 1121  View(s)
Rate this:

I have a DataGrid in WPF with 3 columns. I would like these columns to take up all the space available in the grid. So for example:

Column 1 takes 40% of the grid's width Column 2 takes 30% of the grid's width Column 3 takes 30% of the grid's width

Such that even when resizing the window or grid the columns width resizes accordingly. Anyway I can achieve this.

Thanks in Advance.



Sumit Kesarwani

Total Post:378

Points:2694
Posted on    September-03-2013 7:44 AM

Hi Ashish,

To get the column ratios (like your example of Column 1 = 40%, Column 2 = 30%, Column 3 = 30%), you can specify the ratios with * sizing for column widths as follows:

<Grid>

    <Grid.ColumnDefinitions>

        <ColumnDefinition Width="4*" />

        <ColumnDefinition Width="3*" />

        <ColumnDefinition Width="3*" />

    </Grid.ColumnDefinitions>

</Grid>

Hope this will solve your problem.


Don't want to miss updates? Please click the below button!

Follow MindStick