When pushing a page in Xamarin Forms I can animate it easily by setting the animate property to true
await Navigation.PushModalAsync(NavigationPageHelper.Create(new MyPage(), true);
How can I achieve the same thing when opening the MainPage from App.xaml.cs, in the App() constructor? I see MainPage as a .Animate extension but I've not found any decent examples of how to use it.
InitializeComponent();
MainPage = GetMainPage(); // GetMainPage returns the correct page to open
MainPage.SetValue(NavigationPage.BarTextColorProperty, Color.White);
UPDATE
I found this code to place in the override of OnAppearing, I can see what it should be doing but it doesn't actually do anything, Can anyone see why?
this.Animate("", (s) => Layout(new Rectangle(X, (1 - s) * Height, Width, Height)), 0, 600, Easing.SpringIn, null, null);
You must set a timeout for the animation to take effect. OnAppearing
is called a lot of time before the Page
actually appears. Insert your animation in a timeout, like this..
Task.Delay(1000).ContinueWith(t => BounceUp());
Being BounceUp
your animation story board.
Update: You must also use the modifier async
in OnAppearing
method
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With