#420 – You Can Use Floating Point Values for 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.  You can use integer values preceding each ‘*’ (star) to indicate the relative size of rows or columns.

You can also use floating point values as relative star sizing numbers.  In the example below, we use numbers between 0.0 and 1.0 and set them so that their total adds up to 1.0.  This allows using the values as a ratio of the available space.

    <Grid ShowGridLines="True">
    		<RowDefinition Height="Auto"/>
    		<RowDefinition Height="0.2*"/>
    		<RowDefinition Height="0.5*"/>
    		<RowDefinition Height="0.3*"/>

        <Label Grid.Row="0" Content="Auto-sized"/>
    	<Label Grid.Row="1" Content="0.2* row = 20% avail space" />
    	<Label Grid.Row="2" Content="0.5* row = 50% avail space" />
    	<Label Grid.Row="3" Content="0.3* row = 30% avail space" />