Gerard
Gerard

Reputation: 13397

How do I correctly set the width of DataGridColumn

In a wpf window that has SizeToContent="WidthAndHeight" I have a DataGrid with a column definition:

<DataGridTemplateColum MinWidth="60" ..>

This looks fine, but when I resize and increase the width of the Window, this column stays at the specified width 60. It is the last column of the grid and I would like that this column fills the remaining space, so I added:

<DataGridTemplateColum Width="*" MinWidth="60" ..>

Now when opening the window the column gets a huge width equal to both of my screen widths together ... Is there a simple solution?

Upvotes: 0

Views: 51

Answers (1)

Muds
Muds

Reputation: 4116

Width is working as expected, * will tell grid to take as much space as is available. Its the container of the grid which is not limiting the width of control. fix width of parent.

Upvotes: 1

Related Questions