I\'m creating the columns of a WPF DataGrid
in my C# code. I want one of the columns to stretch to the width of the DataGrid
automatically. In XAML
You're actually using something called a DataGridLength there.
Try something like this:
Grid.ColumnDefinitions[0].Width = new DataGridLength(0.2, DataGridLengthUnitType.Star);
Grid.ColumnDefinitions[1].Width = new DataGridLength(0.8, DataGridLengthUnitType.Star);
That will split the remaining space 80% / 20% between these two columns.
try this
DataGrid1.Width = double.NaN;