fyodorfranz
fyodorfranz

Reputation: 486

Set datagrid column width to star in codebehind

I'm currently trying to set the last column in a DataGrid to take up any remaining horizontal space in the grid by setting its width to star. Here is my current attempt:

dataGrid.Columns[10].Width = DataGridLengthUnitType.Star  // doesn't work

Anyone know if/how this can be achieved? Thanks in advance for any help.

Upvotes: 2

Views: 1692

Answers (1)

thewisegod
thewisegod

Reputation: 1542

Try this:

dataGrid.Columns[10].Width = new DataGridLength(double value here for initial size, DataGridLengthUnitType.Star);

Upvotes: 4

Related Questions