显示进度条/环在Windows 8的应用程序,而网页加载在WebView控件
我添加进度条和进度环同时呼吁异步函数的经验。因为它分别依靠进度条和进度环的唯一IsIndeterminate和IsActive属性一直是一件容易的事。
I have the experience of adding the progress bars and progress rings while calling async functions . That has been an easy job as it relies on only IsIndeterminate and IsActive properties of progress bar and progress ring respectively .
现在我的问题是,如何在应用程序显示一个进度条/圈,而一些网页加载在Windows 8应用的WebView控件。
Now my question is that , how to show a progress bar/ring in the app while some webpage is loading in the webview control of a windows 8 app .
我正在寻找一个属性或事件,它告诉网页的Web视图目前处于加载状态。如果有人碰到过这样的物业来了,请把它写起来否则,如果您有任何其他的解决办法,请你告诉它!
I am searching for a property or event , that tells the web page in web view is currently in loading state . If somebody came across such a property , please write it up else if you have any other solutions , please do tell it !
首先声明委托
public delegate void LoadCompletedEventHandler( object sender, NavigationEventArgs e);
在此情况下,进度条/环必须开始显示了一个区域在逻辑上添加以下代码。
add the following code logically in an area at which event the progress bar/ring must start showing up.
ProgressRing1.IsActive = true; //for progress ring
ProgressBar1.IsIndeterminate = true; //for progress bar
添加此行的控制权转移到它决定了事件是否WebView控件。完全加载网页
Add this line to transfer the control to the event which determines whether the webview control has fully loaded the webpage.
WebView1.LoadCompleted += new Windows.UI.Xaml.Navigation.LoadCompletedEventHandler(WebView1_LoadCompleted);
定义如下函数来处理网页时,已经完全加载发生了什么(你的目标是隐藏在这一点上的时间进度条/圈)
Define the below function to handle what happens when the webpage has been fully loaded ( your aim is to hide the progress bar/ring at this point of time )
void WebView1_LoadCompleted(object sender, Windows.UI.Xaml.Navigation.NavigationEventArgs e)
{
//code for hiding progress bar/ring
ProgressRing1.IsActive = false; //for progress ring
ProgressBar1.IsIndeterminate = false; //for progress bar
}
有关进一步引用您可以检查出这个的 MSDN 页。
For further reference you may check out this MSDN page.