2014-11-05 135 views
1

我需要根據記錄的用戶更改我的應用程序的起始頁。在Silverlight 8.1版本的所有我需要做的就是在清單文件和App.xaml.cs刪除起始頁:在Windows Phone 8.1通用應用程序中設置起始頁

private void Application_Launching(object sender, LaunchingEventArgs e) 
     { 
      Uri uriMain = new Uri("/PivotPage.xaml", UriKind.Relative); 
      Uri uriLogin = new Uri("/MainPage.xaml", UriKind.Relative); 

      var settings = IsolatedStorageSettings.ApplicationSettings; 
      if (!settings.Contains("user_id")) 
       { 
        RootFrame.Navigate(uriLogin); 
       } 
      else 
      { 
       RootFrame.Navigate(uriMain); 
      } 
     } 

但在普及版我想不通我怎麼能做到這一點。爲了在WP 8.1universal應用程序中實現這一點,我需要做些什麼?

編輯: 發現重複Change default startup page for windows phone 8.1 app,對不起

回答

4

在App.xaml.cs尋找

protected override void OnLaunched(LaunchActivatedEventArgs e) 
{ 
    // ... 

    // launch codes 
    // insert here 

    // Ensure the current window is active 
    Window.Current.Activate(); 
} 

我的啓動代碼檢測,看看他們是在手機還是不行,所以我有一個起始頁面是 不同的每個平臺

#if WINDOWS_PHONE_APP 
    if (!rootFrame.Navigate(typeof(PhonePage), e.Arguments)) 
    { 
     throw new Exception("Failed to create initial page"); 
    } 
#endif 
#if WINDOWS_APP 
    if (!rootFrame.Navigate(typeof(DesktopPage), e.Arguments)) 
    { 
     throw new Exception("Failed to create initial page"); 
    }  
#endif 
相關問題