c# - 如何在启动时更改起始页?

标签 c# xaml windows-phone-7 windows-phone-8 windows-phone

目前,我的应用程序在启动时转到 MainPage.xaml(虽然我不知道它在哪里配置)。

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

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

但是 NavigationService 在 App.xaml.cs 中不可用。

如果 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文件中设置静态启动页

<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:

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

关于c# - 如何在启动时更改起始页?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19169657/

相关文章:

c# - 如何在图像上绘制带有轮廓的文本?

c# - 如何获取 Generic.Xaml 中自定义控件的事件处理程序

c# - 当我点击其他地方时,我的 WPF ContextMenu 没有消失

c# - 使用 C# 的 Kinect v2 颜色深度映射

c# - id 的当前上下文不存在

c# - 使用自定义转换器从流中反序列化 Json

c# - 如何将列表从数据库绑定(bind)到 RibbonComboBox?

c# - Windows Phone 类库中的 RecourceDictionary

c# - 在 Windows Mobile 7 中为 ListBoxItem 设置 id 值

c# - 在 wp7 上使用 mvvm light 进行条件绑定(bind)