2013-10-26 109 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。问题已解决

相关问题