Reputation:
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 !
Upvotes: 4
Views: 5691
Reputation: 25450
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).
Upvotes: 5