#407 – Grid Contains Single Row and Column by Default
October 13, 2011 Leave a comment
If you define a Grid, but do not define any rows or columns using the RowDefinitions and ColumnDefinitions properties, the resulting grid will contain a single row and a single column.
<Grid>
<Button Content="I'm in a Grid" Margin="5"/>
</Grid>

Similarly, if you define a Grid and specify multiple columns using the ColumnDefinitions property, but not the RowDefinitions property, you’ll get a single row and the specified number of columns. (The same is true for a single column and explicit number of rows).
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<Label Grid.Column="0" Content="Larry" Margin="10" Background="Lavender"/>
<Label Grid.Column="1" Content="Moe" Margin="10" Background="Magenta"/>
<Label Grid.Column="2" Content="Curly" Margin="10" Background="Cornsilk"/>
</Grid>
