I am trying to make a simple effect where I have an overlay that fades in before pushing a new page for display. I am using a simple FadeTo animation, and I am supplying code for navigation using the returned task's ContinueWith method. I can see that the code gets run, but that the page is not changed. I suspect it may have something to do with threading and the UI, but I am not particularly familiar with how that all works. I created a FadeOverlay class that inherits from BoxView, and I use the following method:
/// <summary>
/// Fades to black and then pushes a new page for display
/// </summary>
/// <param name="page">Page to fade to</param>
/// <param name="removePage">Supply current page if you wish to replace it in stack (for onboarding) </param>
public void FadeToPage(Page page, Page removePage = null)
{
this.FadeTo(1, (uint) FadeTime).ContinueWith(x =>
{
if (removePage != null)
{
Debug.WriteLine("This gets called");
Navigation.InsertPageBefore(new NoAdsPage(), removePage);
Navigation.PopAsync(false);
Debug.WriteLine("This also gets called");
}
else
{
Navigation.PushAsync(page);
}
});
}
Can anyone explain why the page is not being pushed? What is an alternative to achieving the same effect? I tried the same thing using timers, but with no luck