Grid is most flexible
and commonly use layout container. It has format of invisible table means it is
collection of rows and columns. So grid is divided in cells. Grid layout can be
nested means one grid can contain another grid.
We are design a grid
like this:

In above grid we have 3
rows and 3 columns means 9 cells and we design it step by step.
Step 1 Create a grid.
<Grid x:Name="LayoutRoot" ShowGridLines="True" Background="#FF009900" Height="360" Width="480" ></Grid>
<Grid> is a Layout container that has another Silverlight controls
and it uses for effective UI.
x:Name="LayoutRoot" is Grid name for identify to grid in a silverlight
usercontrol each grid has own unique name.So here Grid name is LayoutRoot
Background="#FF009900" It use to set background of whole Grid. Here the alpha value is FF (255), the red value is 00, and green value is 99 and blue value is 00.By passing alpha value we can partly transparent color.
Height="360" It uses to set height of grid in pixel.Here we define 360
pixel.
Step 2 Create row collection for grid.
<Grid.RowDefinitions>
<RowDefinition Height="120"></RowDefinition>
<RowDefinition Height="120"></RowDefinition>
<RowDefinition Height="*"></RowDefinition>
</Grid.RowDefinitions>
In above code we define three rows in one
Grid.RowDefinitions collection.
<Grid.RowDefinitions> It is a property of grid
that contains <RowDefinition> objects for each row.
Note: When we use row than first row is
contain position number 0 and next is respectivly increses by 1.
<Grid.ColumnDefinitions>
<ColumnDefinition Width="160"></ColumnDefinition>
<ColumnDefinition Width="160"></ColumnDefinition>
<ColumnDefinition Width="*"></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.ColumnDefinitions> It is property grid contains
<ColumnDefinition> objects for each column.
Width="160" It is width of column. Here is width is 160. If we use "*" for remaining width of row after define
each column width.Height of column is same as height of row that contains
column.
Here we have nine cell and we put 5
buttons in 5 cells.
<Button Content="West" Grid.Row="1" Grid.Column="2" Height="50" Width="100"></Button>
<Button Content="South" Grid.Row="2" Grid.Column="1" Height="50" Width="100"></Button>
<Button Content="Center" Grid.Row="1" Grid.Column="1" Height="50" Width="100"></Button>
Content="East" It is property of <Button> for assign display text on button. Here text display is
East.
Height="50" It is height of <Button> control in pixel and it is a property.
Width="100" It is width of <Button> control in pixel and it is a property.

Join the conversation! Your thoughts help the community grow.