What does RowDefinition Height="10*" mean in a XAML Grid?

WpfXamlGrid

Wpf Problem Overview


I use Height="*" a bit to mean that the height of the last row should fill to the bottom of the grid.

But what does "10*" mean?

<Grid Name="mainGrid">
	<Grid.RowDefinitions>
		<RowDefinition Height="100" />
		<RowDefinition Height="40" />
		<RowDefinition Height="10*" />
	</Grid.RowDefinitions>
	<Grid.ColumnDefinitions>
		<ColumnDefinition Width="200"  />
		<ColumnDefinition Width="*" />
	</Grid.ColumnDefinitions>
</Grid>

Wpf Solutions


Solution 1 - Wpf

"*" is shorthand for "1*". It's a ratio, so if you have two rows, one with "*" and one with "10*", the former gets 1/11th of the available and the latter gets 10/11th of the space.

In your example above, "10*" is unnecessary - "*" would make more sense because there is only one row using ratio-based sizing, so any ratio will equate to 100% of the available space.

Solution 2 - Wpf

I found the info below from Christian Mosers to be helpful since the Auto, and Fixed sizes on other cells rows or columns will influence the behavior of the * size. See http://wpftutorial.net/GridLayout.html


Fixed Fixed size of logical units (1/96 inch)

Auto Takes as much space as needed by the contained control

Star(*) Takes as much space as available (after filling all auto and fixed sized columns), proportionally divided over all star-sized columns. So 3*/5* means the same as 30*/50*. Remember that star-sizing does not work if the grid size is calculated based on its content.

<Grid>
    <Grid.RowDefinitions>
        <RowDefinition Height="Auto" />
        <RowDefinition Height="Auto" />
        <RowDefinition Height="*" />
        <RowDefinition Height="28" />
    </Grid.RowDefinitions>
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="Auto" />
        <ColumnDefinition Width="200" />
    </Grid.ColumnDefinitions>
</Grid>

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionEdward TanguayView Question on Stackoverflow
Solution 1 - WpfKent BoogaartView Answer on Stackoverflow
Solution 2 - WpfMario LevesqueView Answer on Stackoverflow