Вы можете выполнять итерации дочерних элементов сетки, проверяя их значения строк и столбцов, используя методы Grid.GetRow и Grid.GetColumn, и заменять целевой контент при совпадении значений. Вот пример, протестированный в WPF, но должен работать в Silverlight:
<Grid x:Name="SampleGrid">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition />
<RowDefinition />
<RowDefinition />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Rectangle Fill="Red" Width="20" Height="20" Grid.Row="0" Grid.Column="0" />
<Rectangle Fill="Orange" Width="20" Height="20" Grid.Row="0" Grid.Column="1" />
<Rectangle Fill="Yellow" Width="20" Height="20" Grid.Row="0" Grid.Column="2" />
<Rectangle Fill="Green" Width="20" Height="20" Grid.Row="1" Grid.Column="0" />
<Rectangle Fill="Blue" Width="20" Height="20" Grid.Row="1" Grid.Column="1" />
<Rectangle Fill="Indigo" Width="20" Height="20" Grid.Row="1" Grid.Column="2" />
<Rectangle Fill="Violet" Width="20" Height="20" Grid.Row="2" Grid.Column="0" />
<Rectangle Fill="Black" Width="20" Height="20" Grid.Row="2" Grid.Column="1" />
<Rectangle Fill="Gray" Width="20" Height="20" Grid.Row="2" Grid.Column="2" />
<Button Grid.Row="3" Grid.ColumnSpan="3" Margin="10" x:Name="Swap" Click="Swap_Click" Content="Swap"/>
</Grid>
В обработчике событий:
private void Swap_Click(object sender, RoutedEventArgs e)
{
Ellipse newEllipse = new Ellipse() { Fill = new SolidColorBrush(Colors.PaleGoldenrod), Width = 20d, Height = 20d };
for (int childIndex = 0; childIndex < this.SampleGrid.Children.Count; childIndex++)
{
UIElement child = this.SampleGrid.Children[childIndex];
if (Grid.GetColumn(child) == 2 && Grid.GetRow(child) == 2)
{
this.SampleGrid.Children.Remove(child);
Grid.SetRow(newEllipse, 2);
Grid.SetColumn(newEllipse, 2);
this.SampleGrid.Children.Add(newEllipse);
}
}
}