Search code examples
c#.netxamarin.formslottie

How to wait for lottie animation to finish then do something


I am learning Xamarin.Forms

I would like to continue some action once my Lottie Anymation finish to play

Here is my xaml code :

 <forms:AnimationView Grid.Column="1" IsVisible="False"
                                x:Name="MyYesAddWordAnim"     
                                Animation="YesAddAnim.json"
                                RepeatMode="Infinite"  
                                HeightRequest="40"
                                WidthRequest="40"
                                VerticalOptions="FillAndExpand" 
                                HorizontalOptions="CenterAndExpand"
                                            ClassId="2">

                            </forms:AnimationView>

Here is my code :

 void OnYesAddWord()
    {

        //start my animation
        MyYesAddWordAnim.IsVisible = true;
        MyYesAddWordAnim.PlayAnimation();


        //Do something here 


        //Wait for animation finished then Hide my animation
        MyYesAddWordAnim.IsVisible = true;


    }

thanks for your help


Solution

  • if you look at the docs, AnimationView has an OnFinishedAnimation event handler