8,303
社区成员
发帖
与我相关
我的任务
分享
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);
}