Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在画布上添加了一个矩形,如下所示:
Canvas.SetTop(myRectangle, 150); Canvas.SetLeft(myRectangle, 80); canvas.Children.Add(myRectangle);
现在我想将矩形移动到其他地方,比如 (100, 100)。做这个的最好方式是什么 ?
谢谢 !
如果您只是想立即将它放在那里,您只需再次调用 SetTop 和 SetLeft。否则,您将使用 StoryBoard,可能带有 2 个 DoubleAnimationUsingKeyFrames 元素,指定 Top 和 Left 属性应在所需的时间段内从 150/80 更改为 100/100(初始值为 1 个关键帧,初始值为 1 个关键帧最终值)。