locked
Programmatically Adding Label to Canvas RRS feed

  • Question

  • I am adding via VB.NET a label to a canvas on the screen.  The Canvas is inside a Grid with 1 row and 1 column.

    When I add the Label to the Canvas with a Top and Left property of 1, the label is actaully centered in the Canvas which has a width and height of 200.

    These properties are Bound properties.

    When the screen is finally displayed, the label is centered in the Canvas even though the Top and Left are 1.

    Any ideas???

    Monday, May 21, 2012 4:55 PM

Answers

  • Hi ,

         Have you used something similar to  Canvas.SetTop(label1 , value)  and Canvas.SetLeft(label1 , value)  to set the top and left ?  Because this is the right method to set the left and top for any element within a canvas. 

    Hope it Helps Laughing

     

    Monday, May 21, 2012 9:14 PM

All replies

  • Hi ,

         Have you used something similar to  Canvas.SetTop(label1 , value)  and Canvas.SetLeft(label1 , value)  to set the top and left ?  Because this is the right method to set the left and top for any element within a canvas. 

    Hope it Helps Laughing

     

    Monday, May 21, 2012 9:14 PM
  • Hi,

    I think  the property are not getting applied to the canvas so try to set the different value and observe that the position is still same or different and use the proper way to set the property left and top .

    hope it hepls u.

    Wednesday, May 23, 2012 1:37 AM
  • Can you post your xaml/code-behind for repro? 

    Off topic, you could use a Border rather than Grid (1 row/1 column) if the Canvas is the only element.

    Wednesday, May 23, 2012 10:54 AM