Windows Phone开发(38):动画之PointAnimation
原文:Windows Phone开发(38):动画之PointAnimation
PointAnimation也是很简单的,与前面说到的两个Animation是差不多的,属性也是一样的,如By、From、To,不同的是,PointAnimation是目标值从一点到另一个点。
我有理由相信,大家一定懂的,所以,我不多介绍了,给两个例了热一下身就行了。
例一,让直线动起来。
这个例子,以LineGeometry作为动画的目标对象,通过对StartPoint属性和EndPoint属性进行动画来让直线(其实是线段)动起来。
<Grid>
<Path HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Stroke="Orange" StrokeThickness="6">
<Path.Data>
<LineGeometry x:Name="lg" StartPoint="25,32" EndPoint="185,97"/>
</Path.Data>
</Path>
<Grid.Resources>
<Storyboard x:Name="std" RepeatBehavior="Forever" AutoReverse="True">
<PointAnimation Duration="0:0:5"
Storyboard.TargetName="lg"
Storyboard.TargetProperty="StartPoint"
To="20,375"/>
<PointAnimation Duration="0:0:5"
Storyboard.TargetName="lg"
Storyboard.TargetProperty="EndPoint"
To="407,490"/>
</Storyboard>
</Grid.Resources>
</Grid>
记得了,在页面的Loaded事件中激活动画。
// 构造函数
public MainPage()
{
InitializeComponent(); this.Loaded += (sender, e) =>
{
this.std.Begin();
};
}

例二,对曲线进行动画。
本例对BezierSegment的三个点进行动画,即使贝塞尔曲线“游动”起来。
<Grid>
<Path HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
Stroke="LightGreen" StrokeThickness="12">
<Path.Data>
<PathGeometry>
<PathFigure StartPoint="180,35">
<BezierSegment x:Name="pbm"
Point1="28,180"
Point2="200,270"
Point3="412,700"/>
</PathFigure>
</PathGeometry>
</Path.Data>
</Path>
<Grid.Resources>
<Storyboard x:Name="std" RepeatBehavior="Forever" AutoReverse="True">
<PointAnimation Duration="0:0:3"
Storyboard.TargetName="pbm"
Storyboard.TargetProperty="Point1"
From="27,162" To="415,145"/>
<PointAnimation Duration="0:0:3"
Storyboard.TargetName="pbm"
Storyboard.TargetProperty="Point2"
To="600,400"/>
<PointAnimation Duration="0:0:3"
Storyboard.TargetName="pbm"
Storyboard.TargetProperty="Point3"
To="10,700"/>
</Storyboard>
</Grid.Resources>
</Grid>
后台代码就是在Loaded事件中激活动画,这个大家应该会了。

好了,这节课就这样很轻松地过了。
Windows Phone开发(38):动画之PointAnimation的更多相关文章
- Windows Phone开发(42):缓动动画
原文:Windows Phone开发(42):缓动动画 前面在讨论关键帧动画的时候,我有意把几个带缓动动画的关键帧动画忽略掉,如EasingColorKeyFrame.EasingDoubleKeyF ...
- Windows Phone开发(41):漫谈关键帧动画之下篇
原文:Windows Phone开发(41):漫谈关键帧动画之下篇 也许大家已经发现,其实不管什么类型的动画,使用方法基本是一样的,不知道大家总结出规律了没有?当你找到规律之后,你会发现真的可以举一反 ...
- Windows Phone开发(40):漫谈关键帧动画之中篇
原文:Windows Phone开发(40):漫谈关键帧动画之中篇 一.DiscreteDoubleKeyFrame 离散型关键帧动画,重点,我们理解一下"离散"的意思,其实你查一 ...
- Windows Phone开发(39):漫谈关键帧动画上篇
原文:Windows Phone开发(39):漫谈关键帧动画上篇 尽管前面介绍的几种动画会让觉得很好玩了,但是,不知道你是否发现,在前面说到的一系列XXXAnimation中,都有一个共同点,那就是仅 ...
- Windows Phone开发(37):动画之ColorAnimation
原文:Windows Phone开发(37):动画之ColorAnimation 上一节中我们讨论了用double值进行动画处理,我们知道动画是有很多种的,今天,我向大家继续介绍一个动画类--Colo ...
- Windows Phone开发(36):动画之DoubleAnimation
原文:Windows Phone开发(36):动画之DoubleAnimation 从本节开始,我们将围绕一个有趣的话题展开讨论--动画. 看到动画一词,你一定想到Flash,毕竟WP应用的一个很重要 ...
- Windows Store App 过渡动画
Windows Store App 过渡动画 在开发Windows应用商店应用程序时,如果希望界面元素进入或者离开屏幕时显得自然和流畅,可以为其添加过渡动画.过渡动画能够及时地提示用户屏幕所发 ...
- Windows Phone开发(46):与Socket有个约会
原文:Windows Phone开发(46):与Socket有个约会 不知道大家有没有"谈Socket色变"的经历?就像我一位朋友所说的,Socket这家伙啊,不得已而用之.哈,S ...
- Windows Phone开发(43):推送通知第一集——Toast推送
原文:Windows Phone开发(43):推送通知第一集--Toast推送 好像有好几天没更新了,抱歉抱歉,最近"光荣"地失业,先是忙于寻找新去处,唉,暂时没有下文.而后又有一 ...
随机推荐
- mysql5.6 主从配置
参考网址:http://www.cnblogs.com/zhoujie/p/mysql1.html http://kerry.blog.51cto.com/172631/277414/ 1.配置主库: ...
- MFC程序的消息处理顺序
MFC应用程序中处理消息的顺序 1.AfxWndProc() 该函数负责接收消息,找到消息所属的CWnd对象,然后调用AfxCallWndProc 2.AfxCallWndProc() 该 ...
- Qt之启动外部程序(使用参数很全面,还使用了setProcessChannelMode)
简述 QProcess可以用来启动外部程序,并与它们交互. 要启动一个进程,通过调用start()来进行,参数包含程序的名称和命令行参数,参数作为一个QStringList的单个字符串. 另外,也可以 ...
- [置顶] Asp.Net---css样式的使用方式
Css样式的使用大致分为三种 咱们先来看看一张总括图 1 使用连接的形式调用 有两种发方式调用: A 使用link标签 将样式规则写在.Css的样式文档中,再以<link>标签引入 如 ...
- win8vs2012创建自带sqlServer数据库出错
以前写程序的时候,一直使用的sqlite,今天心血来潮,想用vs2012连接自身带的数据库,结果就出现错误: 啊,看到这个错误,咱赶紧上网搜搜,啊,有关的日志也是比较少的,经过一番苦战之后,终于好了, ...
- DLL五篇
http://www.cnblogs.com/NeuqUstcIim/archive/2009/01/12/1374511.htmlhttp://www.cnblogs.com/NeuqUstcIim ...
- Mojo Mysql utf-8字符集 需要{mysql_enable_utf8 => 1}
get '/api/log_mon/get_log' => sub{ my $c = shift; my $env = $c->param('env'); my $host = $c-&g ...
- C++内存管理学习笔记(6)
/****************************************************************/ /* 学习是合作和分享式的! /* Auth ...
- Codeforces 358 D. Dima and Hares
dp[i][0]表示i号兔子先于i-1号兔子喂食,dp[i][1]反过来. 倒着DP D. Dima and Hares time limit per test 2 seconds memory li ...
- codeforces 592B The Monster and the Squirrel
题目链接:http://codeforces.com/contest/592/problem/B 题目分类:数学,找规律 题目分析:重要的是画图找规律 代码: #include<bits/s ...