如何知道wpf webbrowser是否已完成加载页面 [英] How to know if wpf webbrowser has completed loading the page

查看:93
本文介绍了如何知道wpf webbrowser是否已完成加载页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我目前正在尝试使用在代码中动态创建的Web浏览器来提取网页中的详细信息。但我无法知道负载何时完成。我知道有.LoadCompleted事件。

我尝试了它并且由于某种原因它没有被解雇。如此下垂

但我正在寻找我们以前用于winforms webbrowser控件的类型。检查文件是否准备就好这样



Hi all,
i am currently trying to use a web browser created dynamically in code to extract details in a web page. but i am unable to know when the load is complete. i know there is .LoadCompleted event.
i tried it and it is not firing for some reason. so droped it.
but i am kind of looking for the type where we used to do for winforms webbrowser control. check if the document is ready kind of like this

Do Until WebBrowser1.ReadyState = WebBrowserReadyState.Complete
   Application.DoEvents()
Loop





有类似的东西。所以我可以检查并继续使用剩下的代码。





is there anything similar. so that i can check and continue with the rest of the code.

''Creating the web browser dynamically
                webBrwFrst = New WebBrowser
                webBrwFrst.Navigate(New Uri(strComurl))
'''now i must check if the web page is loaded or not to continue to extract the details of the products in the webpage
''some thing like do until webbrwFrst.loaded= true then
''''Do the extraction
''loop





假设网页类似于我想要的三星或LG产品网页那个页面中的风管列表有链接。

所以我必须等到所有图像和所有细节都加载到页面





assuming the webpage is like Samsung or LG product web page i want al the product list in that page with there link.
so i must wait till all the images and all the details are loaded to the page

<Window x:Class="Window1"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="Window1" Height="320.877" Width="588.123">
    <Grid Height="260.883">
        
        <Label HorizontalAlignment="Left" Margin="0,12,0,0" Name="Label1" Width="100" Height="23.139" VerticalAlignment="Top">Input Excel File:</Label>
        <TextBox  Margin="106,12,57,0" Name="txtbxFlePth" Height="23" VerticalAlignment="Top" />
        <Button HorizontalAlignment="Right" Margin="0,12.139,8,0" Name="btnBrwser" Width="43" Height="23" VerticalAlignment="Top" >Browse</Button>
        <ProgressBar Margin="15.856,115,57,121.883" Name="ProgressBar1" />
        
    </Grid>
</Window>

推荐答案





相反 LoadCompleted ,尝试 DocumentCompleted [ ^ ]。

在您的评论中,您说您没有添加任何网络浏览器控件。我认为 LoadCompleted 事件只会在您在表单上添加了Web浏览器控件时触发。



希望这会有所帮助。
Hi,

Instead of LoadCompleted, try DocumentCompleted[^].
In your comment, you said that you don''t add any web browser control. I think the LoadCompleted event will only fire if you''ve added a web browser control on your form.

Hope this helps.


正如所讨论的,我没有找到任何解决方案,但必须使web浏览器可见或使用表格webbrowser。我使用表单,但巨大的问题是我将不得不使用doevents来加载它并可能给出错误。会尝试任何方式。

非常感谢FOX帮助解决这个问题。如果你们有任何人有其他解决方案请发布。也许它会帮助别人很多,或者我只会使用它
As discussed i didnt find any solution but have to go with making the webbrowser visible or making use of the forms webbrowser. i went with forms but the "HUGE" problem is i will have to use the doevents to get it loaded and might give error. will try it any how.
thank you very much FOX for helping on this. if any of you guys have other solution please post it. may be it will help others a lot or i only might use it


这篇关于如何知道wpf webbrowser是否已完成加载页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆