I try to resize the columns of my DataGrid that the columns just take enough space they needed.
Can't upload an image of what I want it seems.
But for example:
Header |Header |
Content |MoreContent |
How can I make it:
Header |Header2 |
Content|MoreContent|
Tried this in the xaml file:
ColumnWidth="*"
And this:
MyDataGrid.AutoGeneratedColumns += MyDataGrid_AutoGeneratedColumns;
private void MyDataGrid_AutoGeneratedColumns(object sender, EventArgs e)
{
foreach (var oColumn in OgonePaymentInfoDataGrid.Columns)
{
// This is how to set the width to *
oColumn.Width = new DataGridLength(1.0, DataGridLengthUnitType.Star);
}
}
This is how I fill my DataGrid:
MyDataGrid.ItemsSource = items;