Xamarin Forms ProgressBar Stop

Viewed 4458

What is the best way to stop the progress bar animation in Xamarin Forms? Progress is started with:

animProgressBar = async () => { 
 ... 
 await progressBar.ProgressTo (0, 10000, Easing.Linear); 
 ... 
};

I would like to stop the animation and restart it. I have tried things like

progressBar.AbortAnimation("ProgressTo");

without success.

3 Answers

You can also use progressBar.AbortAnimation("Progress");

as it's the actual name of animation in source code.

        public Task<bool> ProgressTo(double value, uint length, Easing easing)
        {
            var tcs = new TaskCompletionSource<bool>();

            this.Animate("Progress", d => Progress = d, Progress, value, length: length, easing: easing, finished: (d, finished) => tcs.SetResult(finished));

            return tcs.Task;
        }

https://github.com/xamarin/Xamarin.Forms/blob/master/Xamarin.Forms.Core/ProgressBar.cs#L37

Related