如何更改起始页?

时间:2013-03-08 02:04:22

标签: windows-phone-8

在开发我的Windows Phone 8应用程序时,我经常想直接启动我正在处理的页面。这并不总是主页面。文章发现here谈论了具有OnLaunched事件处理程序的App。我认为不再是(也许我只是没有看到它)。是否有更新的方法来设置首先启动解决方案中的哪个页面?

5 个答案:

答案 0 :(得分:16)

在应用程序清单中将起始页面更改为您想要的页面。

答案 1 :(得分:4)

找到答案。把它放在这里是为了拯救可能遇到这种情况的其他人。它现在在清单中。去项目>属性> WMAppManifest.xml。在编辑器中更改应用程序UI>导航页面到您需要的页面。

答案 2 :(得分:3)

Windows通用应用程序中的

Shared-> App.xaml.cs

protected override void OnLaunched(LaunchActivatedEventArgs e)
{
    /*...*/
        if (rootFrame.Content == null)
        {
          /*...*/

            // When the navigation stack isn't restored navigate to the first page,
            // configuring the new page by passing required information as a navigation
            // parameter
            if (!rootFrame.Navigate(typeof(MainPage), e.Arguments))
            {
                throw new Exception("Failed to create initial page");
            }
        }
     /*...*/
}

将MainPage更改为您自己的页面的名称

答案 3 :(得分:1)

您也可以在Application_Launching事件中的App.xaml中更改它 使用类似的东西:

App.RootFrame.Navigate(new Uri("/Startup.xaml",UriKind.Relative));

请记住,您必须将“Startup.xaml”更改为您自己的xaml文件。

答案 4 :(得分:1)

对于用C#编写的Windows Phone应用程序:

  1. 打开WMAppManifest.xml文件。
  2. 在Application UI选项卡下,将Navigation Page的值从默认的MainPage.xaml更改为YourPageName.xaml(将YourPageName替换为您要使用的xaml文件的名称)。
相关问题