#419 – How Cell Sizes are Calculated when Using Star Sizing

You can use star sizing when setting the height of rows or width of columns in a Grid to distribute space in a Grid across multiple rows or columns.

Here’s an example.

    <Grid ShowGridLines="True">
    		<RowDefinition Height="Auto"/>
    		<RowDefinition Height="1*"/>
    		<RowDefinition Height="2*"/>
    		<RowDefinition Height="3*"/>

        <Label Grid.Row="0" Content="Auto-sized"/>
    	<Label Grid.Row="1" Content="1* row = 1/6 avail space" />
    	<Label Grid.Row="2" Content="2* row = 1/3 avail space" />
    	<Label Grid.Row="3" Content="3* row = 1/2 avail space" />

The space allocated for each star-sized row is calculated as:

  • n / sum, where n = number preceding * for that row; sum = sum of all numbers preceding star-sized rows
  • Row is given n/sum of the total available space, after allocating space for Auto and Absolute sized rows