使用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. Step By Step(Lua字符串库) (转)

    1. 基础字符串函数:    字符串库中有一些函数非常简单,如:    1). string.len(s) 返回字符串s的长度:    2). string.rep(s,n) 返回字符串s重复n次的结 ...

  2. 3.VS2010C++相关文件说明

    stdafx.h说明:stdafx的英文全称为:Standard Application Framework Extensions(标准应用程序框架的扩展).所谓头文件预编译,就是把一个工程(Proj ...

  3. HDU 2034 人见人爱A-B 分类: ACM 2015-06-23 23:42 9人阅读 评论(0) 收藏

    人见人爱A-B Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Su ...

  4. WT588D播放合成语音时出现某些语句不能正常播报的情况,经过对比其他语句,看似有点不符合逻辑。

    现象:某条语句本该播放完循环,实际确实不断循环第一个字,不能正常播放 原因:用语音合成工具合成该语句时,改了里面的默认音量,导致播放时出现液晶显示错误(感觉好像驱动不了的样子,我就是观察到这个现象才想 ...

  5. Leetcode226:Invert Binary Tree

    Invert a binary tree. 4 / \ 2 7 / \ / \ 1 3 6 9 to 4 / \ 7 2 / \ / \ 9 6 3 1 /** * Definition for a ...

  6. iOS 8自动调整UITableView和UICollectionView布局

    本文转载自:http://tech.techweb.com.cn/thread-635784-1-1.html 本文讲述了UITableView.UICollectionView实现 self-siz ...

  7. HDU3535AreYouBusy(分组背包)

    http://acm.hdu.edu.cn/showproblem.php?pid=3535 分组背包,每一组加了以下三个限制 0 stands for the sets that should ch ...

  8. IOS深入学习(19)之View object

    1 前言 本章主要介绍了View视图对象,包括了其属性,视图间关系和CALayer的简介. 英文原文:http://blog.csdn.net/developer_zhang/article/deta ...

  9. Backbone

    app.js作为backbone 业务代码主模块,内容很简单,在页面加载完之后,对AppView进行了实例化

  10. openNebula 模板实例化成虚拟机【参数名为VM_NAME】

    { "action": { "perform": "instantiate", "params": { "vm ...