question

Rancho-2111 avatar image
0 Votes"
Rancho-2111 asked AlexLi-MSFT commented

Canvas.Setleft sometimes not working in the same condition

       I want to achieve the effect of moving the rectangle edge (one rectangle moves along one side of another rectangle) using Canvas.SetLeft to set the left border of the moving rectangle. **Under the same conditions**, it can be achieved, but sometimes it has The border of the moving rectangle is set to a certain value, **but the graphical interface is not displayed as such** (it will cross the border of a rectangle).
     ` ` Then I tried to set it using element.Margin, but Margin is based on a certain element The borders are set as the starting point.I want to use the upper left corner of Canvas as a reference to set the Margin properties of these rectangles.What should I do?(The above is machine translation content

Looking forward to your reply.
Thanks.

5261-faststoneeditor1.png

我想实现矩形贴边移动的效果(一个矩形沿着另一个矩形的某个边移动)用到Canvas.SetLeft设置移动矩形的左边界,在同一条件下它确实可以实现,但有时它虽然已将移动矩形的边界设置为某个特定的值,但图形界面上却并不是是如此显示(会穿过某个矩形的边界).随后我尝试使用element.Margin来设置,但Margin是以某一个元素的边界为起始点开始设置,我想用Canvas的左上角作为基准来设置这些矩形的Margin属性,应该怎么做呢?



windows-wpf
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi,

Welcome to our Microsoft Q&A platform!

Is your PickedElement inside a Canvas? If not, Canvas.Setleft will not work.

0 Votes 0 ·

Thanks for your reply
It's inside the canvas.My problem is that Canvas.SetLeft (element, value) can change the Left value of the element, but it is not shown in the interface.I don't understand why this is the case.

0 Votes 0 ·

Please provide more code and screenshot

0 Votes 0 ·

0 Answers