Search code examples
c#uwpsplash-screenback-button

Showing Extended SplashScreen Removed my Back Button C# UWP


I have added the BackButton to my UWP App using this article: http://www.wintellect.com/devcenter/jprosise/handling-the-back-button-in-windows-10-uwp-apps then I wanted to add an ExtendedSplashScreen to my App. So I used this article: http://www.c-sharpcorner.com/UploadFile/020f8f/universal-windows-platform-and-extended-splash-screen/

But when I added my ExtendedSplashScreen the BackButton disappeared from the Pages I'm opening after the MainPage. I know it is related to what I'm calling rootframe, but I can't figure out what I should change. Any help?


Solution

  • The problem here is that in DismissExtendedSplash method, the author create a new rootFrame and set it as Window.Current.Content. This override the rootFrame created in App.xaml.cs, so the code for handling the Back Button won't work. To fix this issue, you can just use Window.Current.Content as Frame in DismissExtendedSplash method to get the rootFrame like following:

    private async void DismissExtendedSplash()
    {
        await Task.Delay(TimeSpan.FromSeconds(3));
        // set your desired delay
        //rootFrame = new Frame();
        //MainPage mainPage = new MainPage();
        //rootFrame.Content = mainPage;
        //Window.Current.Content = rootFrame;
        //rootFrame.Navigate(typeof(MainPage)); // call MainPage
        ((Window.Current.Content) as Frame).Navigate(typeof(MainPage));
    }