Placing a control inside a canvas or grid is a two-step process.
- Add a control to the container's child collection
- Set the management location in the container
, .
Button childButton = new Button();
LayoutCanvas.Children.Add(childButton);
Canvas.SetLeft(childButton, 120);
Canvas.SetTop(childButton, 120);
Button childButton = new Button();
LayoutGrid.Children.Add(childButton);
Grid.SetRow(childButton, 2);
Grid.SetColumn(childButton, 2);