1

I need to set the last column of a DataGrid to be 100% of remaining width.

When defining a DataGrid using XAML, I do this:

<DataGridTextColumn Header="Name" IsReadOnly="True" Width="*" />

But I have some situation that I'm using c# code to create the columns.

How to set the width of a column to be something like:

myColumn.Width = *; ?
Beetlejuice
  • 4,292
  • 10
  • 58
  • 84
  • Don't be fooled by the duplicate. `GridLength` and `DataGridLength` are different types, the solution is just similar in structure. – grek40 Feb 25 '18 at 21:34

1 Answers1

3

Maybe you are looking for

new DataGridLength(1, DataGridLengthUnitType.Star);
grek40
  • 13,113
  • 1
  • 24
  • 50