我正在尝试在 windows phone 8 平台上做一些小应用程序。
我正在尝试同时使用网络浏览器和启动画面。
我在应用程序启动之前制作了启动画面。但是我希望当 Web 浏览器组件完成加载移动网站时,启动画面必须消失。
我使用谷歌搜索互联网制作了应用程序,但它在特定时间使用睡眠。例如; “在应用程序启动前等待 10 秒”这是它的代码;
public partial class MainPage : PhoneApplicationPage
{
private Popup _popup;
private BackgroundWorker _backgroundWorker;
public MainPage()
{
ShowPopup();
InitializeComponent();
Browser.Navigated += new EventHandler<System.Windows.Navigation.NavigationEventArgs>(BrowserNavigated);
Browser.Navigating += new EventHandler<NavigatingEventArgs>(BrowserNavigating);
Browser.ScriptNotify += new EventHandler<NotifyEventArgs>(BrowserScriptNotify);
}
private void ShowPopup()
{
_popup = new Popup();
_popup.Child = new PopupSplash();
_popup.IsOpen = true;
StartLoadingData();
}
private void StartLoadingData()
{
_backgroundWorker = new BackgroundWorker();
_backgroundWorker.DoWork += new DoWorkEventHandler(backgroundWorker_DoWork);
_backgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(BackgroundWorkerRunWorkerCompleted);
_backgroundWorker.RunWorkerAsync();
}
void backgroundWorker_DoWork(object sender, DoWorkEventArgs e)
{
//data loading
Thread.Sleep(10000);
}
void BackgroundWorkerRunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
{
this.Dispatcher.BeginInvoke(() =>
{
this._popup.IsOpen = false;
}
);
}
void BrowserScriptNotify(object sender, NotifyEventArgs e)
{
Browser.Navigate(new Uri(e.Value, UriKind.Absolute));
}
void BrowserNavigating(object sender, NavigatingEventArgs e)
{
progressBar1.Visibility = Visibility.Visible;
}
void BrowserNavigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
progressBar1.Visibility = Visibility.Collapsed;
}
}
但我的问题是,我如何制作“当 Web 浏览器组件完成加载移动网站并根据该加载使启动画面消失时”。
有什么例子吗?
我需要帮助,谢谢。