如何在启动时更改起始页? [英] How to change start page at startup?

查看:61
本文介绍了如何在启动时更改起始页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当前,我的应用程序在启动时转到 MainPage.xaml (尽管我不知道它在哪里配置).

my application, currently, goes to the MainPage.xaml at startup (I don't know where it has configured though).

在某些情况下,我希望能够从另一个页面开始.我想我可以将此代码添加到 App.xaml.cs 页面的 Application_Launching()中:

I want to be able to start with another page in some conditions. I think I can add this code to Application_Launching() in App.xaml.cs page:

NavigationService.Navigate(new Uri("/SecondPage.xaml", UriKind.Relative));

NavigationService 在App.xaml.cs中不可用.

but NavigationService is not available in App.xaml.cs.

如果 foo == true ,如何从另一个页面启动应用程序?

How can I start the application with another page if foo == true?

推荐答案

更改 App.Xaml.cs 中的起始页:

private void Application_Launching(object sender, LaunchingEventArgs e)
{

        Uri nUri = new Uri("/SecondPage.xaml", UriKind.Relative);
        ((App)Application.Current).RootFrame.Navigate(nUri);

}

Property \ WMAppManifest.xml 文件中设置静态启动页面

Setting static startup page in Property\WMAppManifest.xml file

<DefaultTask  Name ="_default" NavigationPage="SecondPage.xaml"/>

编辑

尝试:

    private void Application_Launching(object sender, LaunchingEventArgs e)
    {
        Uri nUri = new Uri("/GamePage.xaml", UriKind.Relative);
        RootFrame.Navigate(nUri);
    }

并在 Property \ WMAppManifest.xml 中清除NavigationPage:

and in Property\WMAppManifest.xml clear NavigationPage:

<DefaultTask  Name ="_default" NavigationPage=""/>

这篇关于如何在启动时更改起始页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆