#415 – Setting Grid Row Height and Column Width Properties to Absolute Values

You can set the height of a row or the width of a column in a Grid in one of three different ways.

One way to set a row’s height or a column’s width is to use an absolute value.  This mode is known in Blend as “Pixel sized” because you specify the size of the row or column in pixels.  (Actually, in device independent units, which map to pixels on a 96 dpi display).

    <Grid ShowGridLines="True">
    	<Grid.RowDefinitions>
    		<RowDefinition Height="52"/>
    		<RowDefinition/>
    	</Grid.RowDefinitions>

    	<Label Grid.Row="0" Content="Row 0 is 52 units high" />
    	<Label Grid.Row="1" Content="Row 1 takes up the remaining space" />
	</Grid>


A row or column whose size is set using an absolute number will retain its size when the size of the parent Grid changes.

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

3 Responses to #415 – Setting Grid Row Height and Column Width Properties to Absolute Values

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

  2. emaxy06 says:

    Hello ! Great articule! but i have a dude
    In my app have a row more in the grid, and the middle row has a listbox. My problem is when my listbos is full of item, instead of the show the scrollbar, it overrides the space of 3erd row.

    Thanks for the article!

    • Sean says:

      The containing panel (Grid in this case) will normally dictate the size of the child elements. So if you just drop a ListBox into a grid cell, it will typically take up that cell, but not extend beyond it. If you’re explicitly setting the size of the ListBox, however, and it’s bigger than the cell, then the ListBox could extend outside of the cell.

Leave a comment