我有一个移动点。它有 2 个片段,我需要暂时停止它们之间的动画。 我如何到达它? 有什么办法可以达到这个目的吗?
private void TrainAnim()
{
Path myPath = new Path();
myPath.Stroke = Brushes.Black;
myPath.StrokeThickness = 1;
PathGeometry pathGeometry = new PathGeometry();
PathFigure pathFigure = new PathFigure();
pathFigure.StartPoint = new Point(10, 20);
pathFigure.Segments.Add(new LineSegment(new Point(100, 20), true));
pathFigure.Segments.Add(new LineSegment(new Point(400, 20), true));
pathGeometry.Figures.Add(pathFigure);
myPath.Data = pathGeometry;
Ellipse ellipse = new Ellipse
{
Fill = Brushes.Purple,
Height = 20,
Width = 20,
Margin = new Thickness(0, 0, 0, 0)
};
DoubleAnimationUsingPath anim = new DoubleAnimationUsingPath
{
PathGeometry = pathGeometry,
Duration = TimeSpan.FromSeconds(1),
};
Storyboard storyboard = new Storyboard
{
};
Storyboard.SetTargetName(anim, ellipse.Name);
Storyboard.SetTargetProperty(anim, new PropertyPath(Canvas.LeftProperty));
storyboard.Children.Add(anim);
canvasAnim.Children.Add(ellipse);
canvasAnim.Children.Add(myPath);
ellipse.BeginAnimation(Canvas.LeftProperty, anim);
}
有什么办法吗? canvasAnim 是 MainWindow 上的 Canvas