此刻我完全迷失了。我的动画有什么问题?为什么不运行?任何帮助将非常感谢!我想开发一种圆形的进度条,它正在“滚动”,好像条形图已经填满。
以下代码在MainPage的Loaded Handler中的空UWP应用程序内运行。没有别的......
ArcSegment myArcSegment = new ArcSegment();
myArcSegment.Size = new Size(90, 80);
myArcSegment.SweepDirection = SweepDirection.Clockwise;
PathSegmentCollection myPathSegmentCollection = new PathSegmentCollection();
myPathSegmentCollection.Add(myArcSegment);
PathFigure myPathFigure = new PathFigure();
myPathFigure.StartPoint = new Point(100, 200);
myPathFigure.Segments = myPathSegmentCollection;
PathFigureCollection myPathFigureCollection = new PathFigureCollection();
myPathFigureCollection.Add(myPathFigure);
PathGeometry myPathGeometry = new PathGeometry();
myPathGeometry.Figures = myPathFigureCollection;
Path myPath = new Path();
myPath.Stroke = new SolidColorBrush(Colors.Aqua);
myPath.StrokeThickness = 1;
myPath.Data = myPathGeometry;
PointAnimation mySizeAnimation = new PointAnimation();
mySizeAnimation.Duration = TimeSpan.FromSeconds(2);
mySizeAnimation.From = new Point(90, 80);
mySizeAnimation.To = new Point(500, 200);
Storyboard.SetTarget(mySizeAnimation, myArcSegment);
Storyboard.SetTargetProperty(mySizeAnimation, nameof(ArcSegment.Point));
Storyboard ellipseStoryboard = new Storyboard();
ellipseStoryboard.Children.Add(mySizeAnimation);
myPath.Loaded += delegate (object o, RoutedEventArgs e)
{
ellipseStoryboard.Begin();
};
Canvas containerCanvas = new Canvas();
containerCanvas.Children.Add(myPath);
Content = containerCanvas;
感谢您的帮助!
答案 0 :(得分:1)
哦,我的......我刚读过这篇文章:http://blog.jerrynixon.com/2012/06/windows-8-animated-pie-slice.html
我偶然看到了 EnableDependendAnimation 属性......从未听说过它,但将它设置为true只是让动画运行。我现在就读完了。不管怎样,谢谢!