canvas教程

How to move a Shape on Canvas in WPF?

字号+ 作者:H5之家 来源:H5之家 2017-07-12 08:05 我要评论( )

How to move a Shape on Canvas in WPF?-程序代码库-The program code library

收录日期: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).

 

1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。

相关文章
  • Centos VIM 配置

    Centos VIM 配置

    2017-07-07 12:05

  • Canvas学习:save()和restore()

    Canvas学习:save()和restore()

    2017-07-03 16:02

  • English to Chinese Translation

    English to Chinese Translation

    2017-07-02 18:08

  • 通过Canvas绘图并生成保存为本地图片的方法

    通过Canvas绘图并生成保存为本地图片的方法

    2017-06-28 15:01

网友点评
a