Ejemplo n.º 1
0
        void OnPageAppearing(object sender, EventArgs args)
        {
            ContentPage          page          = (ContentPage)sender;
            StackLayout          layout        = (StackLayout)page.Content;
            ElottieAnimationView animationView = (ElottieAnimationView)layout.Children[0];

            animationView.Play();
        }
Ejemplo n.º 2
0
        void OnPageDisappearing(object sender, EventArgs args)
        {
            ContentPage          page          = (ContentPage)sender;
            StackLayout          layout        = (StackLayout)page.Content;
            ElottieAnimationView animationView = (ElottieAnimationView)layout.Children[0];

            if (animationView.IsPlaying)
            {
                animationView.Stop();
            }
        }
Ejemplo n.º 3
0
        public MainPageCS()
        {
            ItemTemplate = new DataTemplate(() =>
            {
                var animationView = new ElottieAnimationView
                {
                    AutoRepeat        = true,
                    HorizontalOptions = LayoutOptions.FillAndExpand,
                    VerticalOptions   = LayoutOptions.FillAndExpand
                };
                animationView.SetBinding(ElottieAnimationView.AnimationFileProperty, "AnimationFile");

                var contentPage = new ContentPage
                {
                    Content = new StackLayout
                    {
                        Children = { animationView }
                    }
                };

                contentPage.Appearing += (s, e) =>
                {
                    animationView.Play();
                };

                contentPage.Disappearing += (s, e) =>
                {
                    if (animationView.IsPlaying)
                    {
                        animationView.Stop();
                    }
                };

                return(contentPage);
            });
            ItemsSource = LottieDataModel.All;
        }