Search code examples
c#uwpwindows-store-appswin-universal-appwindows-10-universal

How to change the start page of a UWP after a button click


I have a UWP application where I need to change the start page of the application only after the user clicking a button on the third page.

I have tried the following code. The below code helps me navigate to the name page directly skipping the welcome page once the application is opened the second time but I want this to function only after the user clicking a button in the third page.

var roamingSettings = ApplicationData.Current.RoamingSettings;
                    if (roamingSettings.Values.ContainsKey("NotFirstTimeLaunch"))
                    {
                        rootFrame.Navigate(typeof(Name), e.Arguments);
                    }
                    else
                    {
                        roamingSettings.Values["NotFirstTimeLaunch"] = true;
                        rootFrame.Navigate(typeof(WelcomePage), e.Arguments);
                    }

Any help is highly appreciated.


Solution

  • You just need to move this line to your button click event handler:

    roamingSettings.Values["NotFirstTimeLaunch"] = true;