【发布时间】:2023-03-04 20:22:01
【问题描述】:
我已在我的 Windows 7 Phone 应用程序中添加了一个启动画面,但它会在用户每次返回主页时显示。我试图弄清楚我如何只能在应用程序启动期间显示启动画面。我尝试向 App.xaml.cs 添加布尔“firstLoad”,并在运行 Application_Activated 时将其设置为 false,但这不起作用。
我的启动画面由主页处理。该方法称为 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;
}
【问题讨论】:
-
我假设 ShowPopup 检查
firstLoad的值以确定是否显示弹出窗口?您还应该将firstLoad显式初始化为true。 -
我添加了 ShowPopup 方法来表明我正在检查 firstLoad。问题似乎是每次用户进入主页时都会重置该值。
标签: c# silverlight windows-phone-7