Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting ColumnDefinitions in code

Tags:

c#

width

wpf

grid

I'm wondering if there is a way to set a ColumnDefinition Width to * in code, like you can in the xaml file. When trying to set in code GridLength just has the Auto has an option.

<ColumnDefinition Width="*"/>

Thanks for any help.

like image 505
Terco Avatar asked Apr 07 '11 19:04

Terco


1 Answers

You will need to create an instance of the GridLength data type and specify GridUnitType.Star

col.Width = new GridLength(1, GridUnitType.Star);
like image 177
Chris Taylor Avatar answered Oct 23 '22 00:10

Chris Taylor