Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Animation Problem with Xamarin Forms

$
0
0

So I've added a small animation to one of my content pages so when the page loads one of the buttons beats for a second.

I have used the code below :

    protected override async void OnAppearing()
        {
            base.OnAppearing();

            await EditBalance.ScaleTo(1.25, 184);
            await EditBalance.ScaleTo(1, 184);
    }

This worked fine when I tested it on IOS but when I tried to run it on Android I got the following Exception:

04-17 21:27:31.627 E/mono    ( 1347): System.InvalidOperationException: An attempt was made to transition a task to a final state when it had already completed.
04-17 21:27:31.627 E/mono    ( 1347):   at System.Threading.Tasks.TaskCompletionSource`1[TResult].SetResult (TResult result) [0x00013] in <fcbf47a04b2e4d90beafbae627e1fca4>:0 
04-17 21:27:31.627 E/mono    ( 1347):   at Xamarin.Forms.ViewExtensions+<>c__DisplayClass8_0.<ScaleTo>b__1 (System.Double f, System.Boolean a) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\ViewExtensions.cs:166 
04-17 21:27:31.627 E/mono    ( 1347):   at Xamarin.Forms.AnimationExtensions+<>c__DisplayClass13_0`1[T].<AnimateInternal>b__1 (System.Double f, System.Boolean b) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\AnimationExtensions.cs:176 
04-17 21:27:31.627 E/mono    ( 1347):   at Xamarin.Forms.AnimationExtensions.AbortAnimation (Xamarin.Forms.AnimatableKey key) [0x00052] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\AnimationExtensions.cs:150 
04-17 21:27:31.627 E/mono    ( 1347):   at Xamarin.Forms.AnimationExtensions.AnimateInternal[T] (Xamarin.Forms.IAnimatable self, System.String name, System.Func`2[T,TResult] transform, System.Action`1[T] callback, System.UInt32 rate, System.UInt32 length, Xamarin.Forms.Easing easing, System.Action`2[T1,T2] finished, System.Func`1[TResult] repeat) [0x00024] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\AnimationExtensions.cs:171 
04-17 21:27:31.627 E/mono    ( 1347):   at Xamarin.Forms.AnimationExtensions+<>c__DisplayClass7_0`1[T].<Animate>b__0 () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\AnimationExtensions.cs:100 
04-17 21:27:31.627 E/mono    ( 1347):   at Xamarin.Forms.AnimationExtensions.Animate[T] (Xamarin.Forms.IAnimatable self, System.String name, System.Func`2[T,TResult] transform, System.Action`1[T] callback, System.UInt32 rate, System.UInt32 length, Xamarin.Forms.Easing easing, System.Action`2[T1,T2] finished, System.Func`1[TResult] repeat) [0x0009c] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\AnimationExtensions.cs:108 

I have been able to work round the issue by changing the code to:

        protected override async void OnAppearing()
        {
            base.OnAppearing();

            await EditBalance.ScaleTo(1.25, 184).ContinueWith(t => EditBalance.ScaleTo(1, 184));
    }

Which worse but seems a little dirty. Has anyone experienced this or had a similar issue, and had a better work around?

Cheers ....


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>