WPF,轨迹动画停止不了...

wangchunlei187 2014-02-20 11:06:59
我的代码如下
private Storyboard pathAnimationStoryboard = new Storyboard();
private MatrixAnimationUsingPath matrixAnimation = new MatrixAnimationUsingPath();
private void Begin()
{
Img_dh.RenderTransformOrigin = new Point(0.1, 0.1);
Canvas.SetLeft(Img_dh, -Img_dh.ActualWidth * Img_dh.RenderTransformOrigin.X);
Canvas.SetTop(Img_dh, -Img_dh.ActualHeight * Img_dh.RenderTransformOrigin.Y);
MatrixTransform MatrixTransform_01 = new MatrixTransform();
this.RegisterName("MatrixTransform_01", MatrixTransform_01);
Img_dh.RenderTransform = MatrixTransform_01;
Point centerPt = new Point(75, 76);
ese1.Margin = new Thickness(centerPt.X, centerPt.Y, 0, 0); //指示中心点
Canvas.SetLeft(ese1, -ese1.ActualWidth / 2);
Canvas.SetTop(ese1, -ese1.ActualHeight / 2);
PathGeometry aniPath = new PathGeometry();
EllipseGeometry egStandard = new EllipseGeometry(centerPt, 50, 50);
aniPath.AddGeometry(egStandard);
matrixAnimation.PathGeometry = aniPath; //动画的路径
matrixAnimation.Duration = TimeSpan.FromSeconds(3);
matrixAnimation.RepeatBehavior = RepeatBehavior.Forever;
matrixAnimation.DoesRotateWithTangent = true;
Storyboard.SetTargetName(matrixAnimation, "MatrixTransform_01"); //动画的对象
Storyboard.SetTargetProperty(matrixAnimation, new PropertyPath(MatrixTransform.MatrixProperty));
pathAnimationStoryboard.Children.Add(matrixAnimation);
pathAnimationStoryboard.Begin(this);
}


要做一个图片做圆周运动,点击一个按钮的时候让它停止,用pathAnimationStoryboard.Stop(this);和 pathAnimationStoryboard.Remove(this);都无法让动画暂停
...全文
152 回复 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

8,325

社区成员

发帖
与我相关
我的任务
社区描述
游戏开发相关内容讨论专区
社区管理员
  • 游戏开发
  • 呆呆敲代码的小Y
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧