2013-10-26 52 views
0

我已將啓動屏幕添加到我的Windows 7 Phone應用程序,但每當用戶返回主頁時都會顯示。我試圖弄清楚在應用程序啓動過程中我只能顯示啓動畫面。我已經嘗試在App.xaml.cs中添加一個bool「firstLoad」,並在運行Application_Activated時將其設置爲false,但無法使用。WP7啓動屏幕顯示每次用戶轉到主頁

我的啓動畫面由主頁面處理。該方法稱爲ShowPopup

public partial class MainPage : PhoneApplicationPage 
{ 
    private Popup popup; 
    private BackgroundWorker backgroundWorker; 
    private bool firstLoad = true; 

    // Constructor 
    public MainPage() 
    { 
     InitializeComponent(); 

     // Only want to do this once 
     ShowPopup(); 
    } 
} 

    private void ShowPopup() 
    { 
     if (firstLoad) 
     { 
      this.popup = new Popup(); 
      this.popup.Child = new PopUpSplash(); 
      this.popup.IsOpen = true; 
      StartLoadingData(); 
     } 
     firstLoad = false; 
    } 
+0

我假設ShowPopup檢查'firstLoad'的值以確定是否顯示彈出窗口?你也應該顯式初始化'firstLoad'爲true。 – blt

+0

我添加了ShowPopup方法來顯示我正在檢查firstLoad。這個問題似乎是每次用戶轉到主頁時都會重置該值。 –

回答

0

爲App.xaml.cs添加了全局變量。 ShowPopup()運行時,將MainPage.xaml.cs中的變量設置爲false。問題已解決

相關問題