Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Grid Star-Size in code behind

Tags:

c#

wpf

xaml

grid

I have a grid as follows,

<Grid>     <Grid.RowDefinitions>         <RowDefinition Height="0.5*" />         <RowDefinition Height="0.5*" />     </Grid.RowDefinitions> </Grid> 

How do I give the Height = "0.5*" in code behind?

like image 445
Aks Avatar asked Mar 28 '11 13:03

Aks


2 Answers

You can use:

rowDefinition.Height = new GridLength(0.5, GridUnitType.Star); 
like image 81
CodeNaked Avatar answered Oct 02 '22 08:10

CodeNaked


grid.RowDefinitions[0].Height = new GridLength(0.5, GridUnitType.Star); 
like image 40
publicgk Avatar answered Oct 02 '22 07:10

publicgk