locked
Change the start page from MainPage.xaml

    Question

  • I'm using VS 2013 and creating a Windows Store App. I don't see any option under the appmanifest to change the default page to load when the application is started. What I want to do is change the default page from mainpage.xaml to a different page under a directory. Any tip appreciated.

    Sunday, February 16, 2014 6:40 PM

Answers

  • in the app.xaml there is a typeof(MainPage) that you can replace

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Sunday, February 16, 2014 7:27 PM
  • I don't know if this is best Praxis or not but it worked for me go to .App.xaml.cs and search for MainPage (Ctrl + F > MainPage) First result should look like this>

    if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                    {
                        throw new Exception("Failed to create initial page");
                    }

    Change MainPage to what ever Page you want it to be and the Application should launch to that Page every time the Navigation Stack can't be rebuild. The Comment above it should Help you since my VS is not in English IDK what it says in English.

    I am new to this myself so if anybody has a better solution pleas Help.

    Sunday, February 16, 2014 7:32 PM
  • Hi salesruade,

    Try with Dave's solution, there is no such option in appmanifest unlike other desktop applications. mmenter's code should also help you while you create a new win8.0 project.

    Additionally here is a screenshot for you, the red zone is the place that you need change if you are working with win8.1 app. Actually both code are the same, but they looks different. One have the code to throw exception.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.




    Tuesday, February 18, 2014 1:14 AM
    Moderator

All replies

  • in the app.xaml there is a typeof(MainPage) that you can replace

    Microsoft Certified Solutions Developer - Windows Store Apps Using C#

    Sunday, February 16, 2014 7:27 PM
  • I don't know if this is best Praxis or not but it worked for me go to .App.xaml.cs and search for MainPage (Ctrl + F > MainPage) First result should look like this>

    if (!rootFrame.Navigate(typeof(MainPage), args.Arguments))
                    {
                        throw new Exception("Failed to create initial page");
                    }

    Change MainPage to what ever Page you want it to be and the Application should launch to that Page every time the Navigation Stack can't be rebuild. The Comment above it should Help you since my VS is not in English IDK what it says in English.

    I am new to this myself so if anybody has a better solution pleas Help.

    Sunday, February 16, 2014 7:32 PM
  • Hi salesruade,

    Try with Dave's solution, there is no such option in appmanifest unlike other desktop applications. mmenter's code should also help you while you create a new win8.0 project.

    Additionally here is a screenshot for you, the red zone is the place that you need change if you are working with win8.1 app. Actually both code are the same, but they looks different. One have the code to throw exception.

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.




    Tuesday, February 18, 2014 1:14 AM
    Moderator