9

I have a User Control that I need to programmatically add to a Silverlight Grid t a specified Row and Column index. The requirements are such that I will need to insert at arbitrary indices, such that pure databinding is perhaps not ideal.

I would prefer not to have to create the grid from scratch in the code behind. Can this be done? Anyone with example?

PortageMonkey
  • 2,675
  • 1
  • 27
  • 32

1 Answers1

10

Use Grid.Children.Add to add it to the grid, and Grid.SetRow and Grid.SetColumn to set the row and column index. E.g.

Grid.SetRow(myControl, 3);
Grid.SetColumn(myControl, 4);
myGrid.Children.Add(myControl);
itowlson
  • 73,686
  • 17
  • 161
  • 157