How to create the border of a dynamic canvas in Silverlight?

Posted by Subhen on Stack Overflow See other posts from Stack Overflow or by Subhen
Published on 2010-03-27T10:03:16Z Indexed on 2010/03/27 10:13 UTC
Read the original article Hit count: 343

Filed under:
|
|
|

Hi I am creating a Canvas in code behind like below:

Canvas musicPlayerCanvas = new Canvas();
                    musicPlayerCanvas.Background = new SolidColorBrush(Colors.White);
                    musicPlayerCanvas.Height = 80;
                    musicPlayerCanvas.Width = 1018;
LayoutRoot.Children.Add(musicPlayerCanvas);

musicPlayerCanvas.Children.Add(playingText);
musicPlayerCanvas.Children.Add(albumImage);

Now how can I add border to the canvas from the codebehind.

I tried with creating a Border and assigning a child like below:

Border myBorder = new Border();
                    //Border Proporties



                    Canvas.SetTop(musicPlayerCanvas, 26);
                    Canvas.SetLeft(musicPlayerCanvas, 154);
                    LayoutRoot.Children.Add(musicPlayerCanvas);
                    myBorder.Child = musicPlayerCanvas;

It is not working for me . Any help please.

Thanks, Subhen

© Stack Overflow or respective owner

Related posts about c#

Related posts about silverlight-3.0