PathAnimation

简介: 原文:PathAnimation使用Blend制作PathAnimation 1:选中Path转换为运动路径 2:选择目标对象   PathAnimation使用动态的Path PathAnimation动画在播放的时候,PahtGeometry是已经确定的,不会改变,不会实时的根据Pa...
原文: PathAnimation

使用Blend制作PathAnimation

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

2:选择目标对象

 

PathAnimation使用动态的Path

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

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

 1    <Path x:Name="path" Stroke="DarkGray" StrokeThickness="3">
 2             <Path.Data>
 3                 <PathGeometry>
 4                     <PathFigure 
 5                         StartPoint="{Binding Center, ElementName=ptStart}">
 6                         <BezierSegment 
 7                             Point1="{Binding Center, ElementName=ptCtrl1}"
 8                             Point2="{Binding Center, ElementName=ptCtrl2}"
 9                             Point3="{Binding Center, ElementName=ptEnd}"/>
10                     </PathFigure>
11                 </PathGeometry>
12             </Path.Data>
13         </Path>

 

 1  private void Button_Click(object sender, RoutedEventArgs e)
 2         {
 3             Canvas.SetLeft(this.truck, -this.truck.ActualWidth / 2);
 4             Canvas.SetTop(this.truck, -this.truck.ActualHeight / 2);
 5             this.truck.RenderTransformOrigin = new Point(0.5, 0.5);
 6 
 7             MatrixTransform matrix = new MatrixTransform();
 8             this.truck.RenderTransform = matrix;
 9 
10             NameScope.SetNameScope(this, new NameScope());
11             this.RegisterName("matrix", matrix);
12 
13             MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
14             matrixAnimation.PathGeometry = this.path.Data.GetFlattenedPathGeometry();
15             matrixAnimation.Duration = new Duration(TimeSpan.FromSeconds(5));
16 
17             //matrixAnimation.AutoReverse = true;   //重复
18             //matrixAnimation.IsOffsetCumulative = !matrixAnimation.AutoReverse;
19             //matrixAnimation.RepeatBehavior = RepeatBehavior.Forever;
20             matrixAnimation.DoesRotateWithTangent = false;   //旋转
21 
22             Storyboard story = new Storyboard();
23             story.Children.Add(matrixAnimation);
24             Storyboard.SetTargetName(matrixAnimation, "matrix");
25             Storyboard.SetTargetProperty(matrixAnimation, new PropertyPath(MatrixTransform.MatrixProperty));
26             story.Begin(this);
27         }

 

目录
相关文章
|
9月前
|
前端开发 JavaScript 搜索推荐
解密: SPA 与 MPA
单页面应用(SPA)是一种Web应用架构,其中所有的内容和功能都包含在单一的HTML页面中。这种应用在用户与界面交互时不会进行全页刷新,而是通过动态更新页面上的局部内容来提供流畅的用户体验。多页面应用(MPA)是一种传统的Web应用程序架构,它由多个页面组成,每个页面都是一个独立的文档,通常包含自己的一套JavaScript、CSS等资源。当用户在应用中导航时,浏览器会重新加载整个页面和相关的资源。
PadLeft 和 PadRight
原文:PadLeft 和 PadRight 1 PadLeft    即:向已知字符串左边补充字符,使整个字符串到达指定长度 1 CREATE FUNCTION PadLeft 2 ( 3 @VarOrgan varchar(10),/*原始字符*/ 4 @To...
774 0
|
云栖大会
apaas 、ipaas
apaas 、ipaas自制脑图
210 0
apaas 、ipaas
|
iOS开发 容器
willMoveToParentViewController和didMoveToParentViewController
<p class="p1" style="color:rgb(54,46,43); font-family:Arial; font-size:14px; line-height:26px"> <span style="font-size:18px"><strong>iOS 5.0 后UIViewController新增:willMoveToParentViewController和did
1850 0
PAT有几个pat
字符串APPAPT中包含了两个单词“PAT”,其中第一个PAT是第2位§,第4位(A),第6位(T);第二个PAT是第3位§,第4位(A),第6位(T)。 现给定字符串,问一共可以形成多少个PAT?
155 0
|
存储 安全 数据安全/隐私保护
|
6月前
|
SQL Java 数据库
什么是 PagingAndSortingRepository?
【8月更文挑战第21天】
146 0
|
8月前
PAT乙级 1016 部分A+B
PAT乙级 1016 部分A+B

热门文章

最新文章