收录日期:2017/07/12 08:07:33 时间:2011-09-12 16:54:56 标签:c#,.net,wpf,graphics,move
I added a Rectangle to a Canvas like this:
Canvas.SetTop(myRectangle, 150); Canvas.SetLeft(myRectangle, 80); canvas.Children.Add(myRectangle);Now I want to move the rectangle to other place, say (100, 100). What is the best way to do this ?
Thanks !
If you just want it there instantly, you'd just call SetTop and SetLeft again. Otherwise you'd use a StoryBoard, probably with 2 DoubleAnimationUsingKeyFrames elements that specify the Top and Left properties should change from 150/80 to 100/100 over your desired period of time (1 key frame for the initial value, 1 key frame for the final value).