Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you dynamically place a control on a canvas in Silverlight?

I'm trying to place a control that I have created on my Canvas. The idea is to be able to dynamically add them on the fly. Like on a button click or at the end of a DispatchTimer. I have the following, but it doesn't work:

    FirstCircleControl mc = new FirstCircleControl();
    Canvas.SetLeft(mc, 100);
    Canvas.SetTop(mc, 100);

I don't see any control appear...

like image 552
Ry. Avatar asked Apr 15 '09 00:04

Ry.


1 Answers

You need to add the control to the Canvas first.

yourCanvas.Children.Add(mc)
like image 193
sipsorcery Avatar answered Nov 14 '22 21:11

sipsorcery