Let's imagine we would like to add a button at a specific cell (row:column) in our grid control. How this could be done? How to define the row and column of that cell? Well, the answer is pretty easy - you just have to define values for the two attached properties Grid.Row and Grid.Column inside the control you wish to add. Like this:
Xaml
<Grid x:Name="MyGrid" ShowGridLines="True">
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Button x:Name="MyButton" Content="Button at Cell(R:0, C:1)" Grid.Row="0" Grid.Column="1"></Button>
</Grid>
C#
Grid MyGrid = new Grid();
RowDefinition row1 = new RowDefinition();
RowDefinition row2 = new RowDefinition();
MyGrid.RowDefinitions.Add( row1 );
MyGrid.RowDefinitions.Add( row2 );
ColumnDefinition col1 = new ColumnDefinition();
ColumnDefinition col2 = new ColumnDefinition();
MyGrid.ColumnDefinitions.Add( col1 );
MyGrid.ColumnDefinitions.Add( col2 );
Button MyButton = new Button();
MyButton.SetValue( Grid.RowProperty, 0 );
MyButton.SetValue( Grid.ColumnProperty, 1 );
Do you see the row before the last one, the row where we add the button? OK, if you see it, then you also probably notice the two properties Grid.Row="0" Grid.Column="1". Using these attached properties you actually define the exact row and column where your control should be inserted to. And last but not least, don't forget that the row and column indexes are zero based.
That's it!