使用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. c#与vb.net在App_Code里面编译要通过,需要以下web.config的配置

    web.config的配置: <system.web> <codeSubDirectories> <add directoryName="VB"/&g ...

  2. Axis2在Web项目中整合Spring

    一.说明: 上一篇说了Axis2与Web项目的整合(详情 :Axis2与Web项目整合)过程,如果说在Web项目中使用了Spring框架,那么又改如何进行Axis2相关的配置操作呢? 二.Axis2 ...

  3. Ubuntu下实用命令收集 --新增 删除 环境变量

    1. 关闭防火墙: sudo ufw disable 2. 设置IPV4地址和网关: ifconfig eth0 up %s netmask %s route del default gw 192.1 ...

  4. 给Adobe Reader添加书签功能

    Adobe Acrobat Professional和Adobe Reader都是Adobe公司的产品.前者用来编辑制作PDF文档,后者只能用来阅读PDF.令人郁闷的是Adobe Reader中虽然有 ...

  5. python 加密解密(base64, AES)

    1. 使用base64 s1 = base64.encodestring('hello world') s2 = base64.decodestring(s1) print s1, s2 结果 1 2 ...

  6. 1001.A+B Format (20)(思路,bug发现及其修改,提交记录)

    https://github.com/031502316a/object-oriented/tree/master/1001 ---恢复内容开始--- 1.解题思路 一开始见到题目时,感觉难的就是输出 ...

  7. CCF 201312-1 出现次数最多的数 (水题)

    问题描述 给定n个正整数,找出它们中出现次数最多的数.如果这样的数有多个,请输出其中最小的一个. 输入格式 输入的第一行只有一个正整数n(1 ≤ n ≤ 1000),表示数字的个数. 输入的第二行有n ...

  8. Javascript 正则表达式校验数字

    $("input[datatype=number]").blur(function () {                      var str = $(this).val( ...

  9. Slave延迟很大的优化方法总结(MySQL优化)

    [http://www.cstor.cn/textdetail_9146.html] 一般而言,slave相对master延迟较大,其根本原因就是slave上的复制线程没办法真正做到并发.简单说,在m ...

  10. NISSAN 尼桑 J1962 诊断座

    J1962诊断座: J1962/16 ........ 常火线 +BATJ1962/  8 ........ 点火开关打开信号 +IGNJ1962/  5 ........ 发动机搭铁线; 逻辑地J1 ...