Question

I made a C# store app in Visual studio 2013. All of the sudden the startup form is changed, so its no longer the Mainpage. I cannot find how to resolve this problem.
I found a link where I could do something in the properties of my project, but I was unable to resolve the problem.

Does anyone know how to change the startup form for a C# store app in Visual Studio 2013?

edit: here is the OnLaunched method as told in comments.

        protected override async void OnLaunched(LaunchActivatedEventArgs e)
    {

#if DEBUG
        if (System.Diagnostics.Debugger.IsAttached)
        {
            this.DebugSettings.EnableFrameRateCounter = true;
        }
#endif

        Frame rootFrame = Window.Current.Content as Frame;

        if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
        {
            await CatalogApp.Common.SuspensionManager.RestoreAsync();
        }
        if (rootFrame == null)
        {
            // Create a Frame to act as the navigation context and navigate to the first page
            rootFrame = new Frame();
            CatalogApp.Common.SuspensionManager.RegisterFrame(rootFrame, "appFrame");
            // Set the default language
            rootFrame.Language = Windows.Globalization.ApplicationLanguages.Languages[0];

            rootFrame.NavigationFailed += OnNavigationFailed;

            if (e.PreviousExecutionState == ApplicationExecutionState.Terminated)
            {
            }

            // Place the frame in the current Window+
            Window.Current.Content = rootFrame;
        }

        if (rootFrame.Content == null)
        {
            if (!rootFrame.Navigate(typeof(ShowItems), e.Arguments))
            {
                throw new Exception("Failed to create initial page");
            }

            rootFrame.Navigate(typeof(MainPage), e.Arguments);
        }
        Window.Current.Activate();
    }
Was it helpful?

Solution

There is probably is a navigation statement like: rootFrame.Navigate(typeof(ItemsPage), e.Arguments); in the

protected override async void OnLaunched(LaunchActivatedEventArgs e)

override in App.xaml.cs

If you are using this default, check typeof(ItemsPage) and the e.Argument statements.

Keep in mind, by default at activation, the application redirects to the last opened window.

UPDATE

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

rootFrame.Navigate(typeof(MainPage), e.Arguments);

is a double navigation: first navigate to ShowItems, if succeeded navigate to MainPage. Why is that? I think this will lead to unexpected results.

Please try to remove

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

and check the results.

By the way: Which one is the page you want to start with?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top