2013-03-08 63 views
5

在開發我的Windows Phone 8應用程序時,我經常想直接進入正在處理的頁面。這並不總是主頁。文章發現here談論有一個OnLaunched事件處理程序的應用程序。我認爲這不再(也許我只是沒有看到它)。是否有更新的方法來設置解決方案中的哪個頁面首先啓動?如何更改起始頁?

回答

16

在App清單中,將起始頁面更改爲所需的頁面。

4

找到了答案。把它放在這裏來拯救可能遇到這個問題的其他人。現在在清單中。轉到項目>屬性> WMAppManifest.xml。在編輯器中將「應用程序UI」>「導航頁面」更改爲您需要的頁面。

1

您還可以通過使用類似改變它的App.xaml在Application_Launching事件 :

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

請記住,你必須「Startup.xaml」更改爲自己的XAML文件。

在Windows
3

通用的應用程序:

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"); 
      } 
     } 
    /*...*/ 
} 

改變通首頁自己的網頁

1

對於用C#編寫的Windows Phone應用程序的名稱:

  1. 打開WMAppManifest.xml文件。
  2. 在應用程序UI選項卡下,將導航頁面的值從默認MainPage.xaml更改爲YourPageName.xaml(將YourPageName替換爲要使用的xaml文件的名稱)。