show progress bar/ring in windows 8 app while a webpage is loading in webview control

喜夏-厌秋 提交于 2019-12-06 05:41:16

first declare the delegate

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

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
}

For further reference you may check out this MSDN page.

You should be able turn busy off in DocumentCompleted or Navigated, with Navigated I believe you'd have to compare with the original link as it fires on redirects.

Just a correction, If you are using it for phone, then instead of

`new Windows.UI.Xaml.Navigation.LoadCompletedEventHandler(WebView1_LoadCompleted);`

the event handler would be

`new System.Windows.Navigation.LoadCompletedEventHandler(WebView1_LoadCompleted);`
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!