views:

842

answers:

1

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?

+3  A: 

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