68

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>
Edward Tanguay
  • 189,012
  • 314
  • 712
  • 1,047

2 Answers2

117

"*" 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.

Kent Boogaart
  • 175,602
  • 35
  • 392
  • 393
  • 3
    Very helpful answer. Official documentation's limited examples don't explicitly declare a '*' to indicate ratio based spacing. – ford Sep 22 '11 at 17:20
  • @ford it does but you need to change the version to silverlight [link]http://msdn.microsoft.com/en-us/library/system.windows.controls.grid.rowdefinitions(v=vs.95).aspx – Choco Smith Jul 31 '13 at 11:55
25

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>
Mario Levesque
  • 1,017
  • 13
  • 13