Programmatically setting the width of a grid column with * in WPF
I want to programmatically configure a wpf grid. I want to be able to set a grid with 2 columns, the first taking up 20% of available space, the second taking up 80%. In xaml I would use the * operator but I cant work out how to do this programmatically. In Xaml I would do: <Grid> <Grid.ColumnDefinitions> <ColumnDefinition width="20*" /> <ColumnDefinition width="80*" /> </Grid> In code I want to do: Grid grid = new Grid(); grid.ColumnDefinitions.Add( new ColumnDefinition(20*) ); grid.ColumnDefinitions.Add( new ColumnDefinition(80*) ); Please could someone advise. Grid grid = new Grid();