开发者

WebBrowser control: show to user when it's navigating

开发者 https://www.devze.com 2023-02-24 04:03 出处:网络
I\'m developing a Windows Phone application. I\'m using WebBrowser control and I want to show to users when is loading a page. I\'ve used events:

I'm developing a Windows Phone application.

I'm using WebBrowser control and I want to show to users when is loading a page. I've used events:

private void Browser_Navigating(object sender, Microsoft.Phone.Controls.NavigatingEventArgs e)
{
    LoadingText.Visibility = System.Windows.Visibility.Visible;
}

private void Browser_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
{
    LoadingText.Visibility = System.Windows.Visibil开发者_如何学编程ity.Collapsed;
}

But it doesn't work.

Any advice?


I think your problem is in the navigated event - this

From msdn

Occurs when the WebBrowser control has navigated to a new document and has begun loading it.

This obviously could be long before the document is actually rendered.

I'm not sure there's any event to use to determine when the page is fully loaded and is rendered.

In iron7, I detect when the editor is loaded by using a timer - that timer keeps trying to call javascript methods in the script - I know these are only available after the document javascript ready occurs.


Try using the LoadCompleted event:

private void Browser_LoadCompleted(object sender, NavigationEventArgs e)
{
    LoadingText.Visibility = System.Windows.Visibility.Collapsed;
}

This ensures that once everything is rendered the loading bar will disappear.

See the msdn page: http://msdn.microsoft.com/en-us/library/microsoft.phone.controls.webbrowser.loadcompleted(v=VS.92).aspx

(I think Stuart was looking at the Windows Forms implementation of WebBrowser rather than the Phone Control)

0

精彩评论

暂无评论...
验证码 换一张
取 消