使用Blend制作PathAnimation

1:选中Path转换为运动路径

2:选择目标对象

PathAnimation使用动态的Path

PathAnimation动画在播放的时候,PahtGeometry是已经确定的,不会改变,不会实时的根据Path的改变动画进行调整,所以是不能进行绑定

只有在每一次需要播放动画之前读取相关的Path的Data,读取当前的PathGeometry然后开始动画

    <Path x:Name="path" Stroke="DarkGray" StrokeThickness="3">
<Path.Data>
<PathGeometry>
<PathFigure
StartPoint="{Binding Center, ElementName=ptStart}">
<BezierSegment
Point1="{Binding Center, ElementName=ptCtrl1}"
Point2="{Binding Center, ElementName=ptCtrl2}"
Point3="{Binding Center, ElementName=ptEnd}"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
  private void Button_Click(object sender, RoutedEventArgs e)
{
Canvas.SetLeft(this.truck, -this.truck.ActualWidth / );
Canvas.SetTop(this.truck, -this.truck.ActualHeight / );
this.truck.RenderTransformOrigin = new Point(0.5, 0.5); MatrixTransform matrix = new MatrixTransform();
this.truck.RenderTransform = matrix; NameScope.SetNameScope(this, new NameScope());
this.RegisterName("matrix", matrix); MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
matrixAnimation.PathGeometry = this.path.Data.GetFlattenedPathGeometry();
matrixAnimation.Duration = new Duration(TimeSpan.FromSeconds()); //matrixAnimation.AutoReverse = true; //重复
//matrixAnimation.IsOffsetCumulative = !matrixAnimation.AutoReverse;
//matrixAnimation.RepeatBehavior = RepeatBehavior.Forever;
matrixAnimation.DoesRotateWithTangent = false; //旋转 Storyboard story = new Storyboard();
story.Children.Add(matrixAnimation);
Storyboard.SetTargetName(matrixAnimation, "matrix");
Storyboard.SetTargetProperty(matrixAnimation, new PropertyPath(MatrixTransform.MatrixProperty));
story.Begin(this);
}

PathAnimation的更多相关文章

  1. WPF中的PathAnimation(路径动画)

    原文:WPF中的PathAnimation(路径动画) WPF中的PathAnimation(路径动画)                                                 ...

  2. 26.Qt Quick QML-RotationAnimation、PathAnimation、SmoothedAnimation、Behavior、PauseAnimation、SequentialAnimation和ParallelAnimation

    1.RotationAnimationRotationAnimation也是继承于PropertyAnimation组件,但是它有点特殊,它只需要指定taget目标对象,并且不需要指定property ...

  3. iOS CoreAnimation详解(一) 有关Layer的动画

    以前由于项目需要 也写了一些动画 ,但是知识不系统,很散.这段时间趁着项目完成的空袭,来跟着大神的脚步系统的总结一下iOS中Core Animation的知识点. 原博客地址:http://blog. ...

  4. 利用layer的mask属性实现逐渐揭示的动画效果

    github上又看到个不错的动画(https://github.com/rounak/RJImageLoader),如图: 所以就想来自己实现以下 不试不知道,这个动画还真不是看上去那么简单,我自己想 ...

  5. iOS 动画绘制线条颜色渐变的折线图

    效果图 .................... 概述 现状 折线图的应用比较广泛,为了增强用户体验,很多应用中都嵌入了折线图.折线图可以更加直观的表示数据的变化.网络上有很多绘制折线图的demo,有 ...

  6. pyqt官方示例

    文件夹 PATH 列表 卷序列号为 00000058 F027:7BEC C:. ├─activeqt │ └─webbrowser │ ├─icons │ └─pycache ├─animation ...

  7. iOS 动画组

    其实早在一个多月以前就已经实现了动作组播放的功能,不过当时感觉好像没有什么难度并没有放在心上,今天突然要用到动画组,发现已经忘记了,所以又将原来的代码翻出来看了下.最后决定还是写下来,以备不时之需.动 ...

  8. CAShapeLayer(持续更新)

    CAShapeLayer 之前讲过CALayer动画相关知识,再来看看更加复杂的CAShapeLayer相关的动画知识. 普通CALayer在被初始化时是需要给一个frame值的,这个frame值一般 ...

  9. iOS简易柱状图(带动画)--新手入门篇

    叨逼叨 好久没更新博客了,才几个月,发生了好多事情,处理了好多事情.不变的是写代码依然在继续. 做点啥子 看看objective-c的书,学着写了个柱状图,只是练习的demo而已,iOS上的图表控件已 ...

随机推荐

  1. 第二百一十一天 how can i 坚持

    参与感.做项目要有激情. 睡觉.

  2. 使用MSSQL,连接oracle,对oracle数据进行操作

    EXEC sp_addlinkedserver--创建链接服务器.链接服务器让用户可以对 OLE DB 数据源进行分布式异类查询. @server = 'Mktg',--要创建的链接服务器的名称.s ...

  3. Excel合并单元格数据

    1.=A1&B1 2.=CONCATENATE(A1,B1)

  4. 在jybot下跑Selenium2Library

    应用场景:项目组要将原有SeleniumLibrary写的脚本切换到Selenium2Library(后称S2L)下,但是原来有很多Java写的库,综合考虑认为还是在Jython下跑比较合适.但是安装 ...

  5. Eclipse报错 Unable to execute dex: Multiple dex files define Lcom/kenai/jbosh/AbstractAttr

    这个错误时jar包重复造成的!! 看看有没有多的private Libary  删除即可!!!

  6. setTimeout setInterval 区别 javascript线程解释

    原文:http://www.iamued.com/qianduan/1645.html 今天看到这篇文章,学到了不少东西 特此发出来 和大家分享 JavaScript的setTimeout与setIn ...

  7. Junit 测试断言说明

    Assert.assertEquals("发生错误时报告消息","预期值","生产值"); Assert.assertEquals(&quo ...

  8. Java集合框架(JCF)之collention

    一.概念:是为了实现某一目的或功能而预先提供的一系列封装好了的具有继承或实现的类与接口. 二.特点: 1.元素的类型可以不同  2.集合长度可变 3.空间不固定 三.collection与collec ...

  9. maven中如何打包源代码

    http://yanghaoyuan.iteye.com/blog/2032406 使用Maven对项目部署太方便了,特别是依赖关系,最近学习使用Maven,为了备忘和技术的分享特意注册个账号记录到博 ...

  10. WEB前端性能优化小结

    转:http://www.gafish.net/archives/1514 对前端开发工程师来说,前端性能优化的重要性是不言而喻的,最为大家所知的是YSLOW的23条优化规则,在我的理解中,性能优化不 ...