#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" />


About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #420 – You Can Use Floating Point Values for Star Sizing

  1. Pingback: Dew Drop – November 1, 2011 | Alvin Ashcraft's Morning Dew

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: