Changing Position of an Element Programmatically in WPF

前端 未结 6 1302
时光说笑
时光说笑 2020-12-16 11:40

I did not knew that this simple thing would be slightly complicated. I have a Canvas in which I am trying to add Ellipse dynamically. Here is the code:

<         


        
6条回答
  •  清酒与你
    2020-12-16 12:13

    The reason 100 doesn't work is that SetValue() interprets it as an integer, but Canvas.Top & Canvas.Left are doubles. Try 100d instead. Also SetLeft() & SetTop() work because they expect doubles.

提交回复
热议问题