【问题标题】:WP7 Splash Screen showing everytime user goes to home page每次用户进入主页时都会显示 WP7 启动画面
【发布时间】: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


【解决方案1】:

向 App.xaml.cs 添加了全局变量。运行 ShowPopup() 时,将 MainPage.xaml.cs 中的变量设置为 false。问题解决了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-28
    • 2012-09-11
    • 1970-01-01
    • 1970-01-01
    • 2012-05-18
    • 2020-12-27
    相关资源
    最近更新 更多