I'm trying to figure out how to do animations in Avalonia.
I have a path with 4 linesegements and I want to animate each point to a new position. In WPF I have done it like this:
public void AnimatePoints(PointCollection pts, TimeSpan timespan, bool randomized = true, Action onFinished = null)
{
Points = PointCollection.Parse(PathString);
//PathFigure needs an animation too (for the start point), otherwise the first point always stays in one place
var pfa = new PointAnimation(pts[0], timespan);
if (onFinished != null)
{
pfa.Completed += (sender, args) => onFinished();
}
PathFigure.BeginAnimation(PathFigure.StartPointProperty, pfa);
for (int i = 0; i < pts.Count; i++)
{
var pa = new PointAnimation(pts[i], timespan);
if (randomized)
{
LineSegments[i].BeginAnimation(LineSegment.PointProperty, pa);
}
else
{
LineSegments[i].BeginAnimation(LineSegment.PointProperty, pa);
}
}
}
How can I do the same in Avalonia using code? I've tried with a PathTransition but neither PathFigure nor LineSegments are animateable.