I want to understand how RowDefinition in XAML works. [Resolved]

Posted by Zhang JingChu under C# on 10/2/2011 | Points: 10 | Views : 2409 | Status : [Member] | Replies : 4
I want to understand how RowDefinition in XAML works. Is the Height label a percentage or a pixel size?




Responses

Posted by: Ndebata on: 10/2/2011 [Member] Starter | Points: 50

Up
0
Down

Resolved
Rowdefinition is used to set the height of a row in a grid.
This value can be an exact value or a ratio.
<RowDefinition Height="50"/>

<RowDefinition Height="*"/>
<RowDefinition Height="3*"/>


In the above case 1st row value is absolute or fixed, them from the remaining space 2nd row height will be 25% and 3rd row will be 75%.
By default it is pixel but you are free to use other units like in , cm , pt.

<RowDefinition Height="50 in"/>

<RowDefinition Height="50 pt"/>
<RowDefinition Height="50 cm"/>


Zhang JingChu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: SheoNarayan on: 10/2/2011 [Administrator] HonoraryPlatinum | Points: 25
Posted by: Zhang JingChu on: 10/4/2011 [Member] Starter | Points: 25

Up
0
Down
Can height of a row and width of a column be changed dynamically at runtime?

Zhang JingChu, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Ndebata on: 10/4/2011 [Member] Starter | Points: 25

Up
0
Down
Yes you can change those in runtime
XAML
<RowDefinition x:Name="row1" Height="*"></RowDefinition>

You can choose different unit type from the GridUnitType enum with a value.
C#
row1.Height = new GridLength(200);

row1.Height = new GridLength(200, GridUnitType.Pixel);
row1.Height = new GridLength(3,GridUnitType.Star);


Thanks,
Debata

Zhang JingChu, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response