我怎么投了System.Windows.Control WebBrowser.Document到mshtml.MSHTMLDocumentClass? [英] How do I cast a System.Windows.Control WebBrowser.Document to an mshtml.MSHTMLDocumentClass?

查看:364
本文介绍了我怎么投了System.Windows.Control WebBrowser.Document到mshtml.MSHTMLDocumentClass?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 web浏览器,一个WPF窗口内的负载。我需要在 web浏览器加载网页的标题

I have a WebBrowser that loads inside a WPF window. I need to get the title of the web page loaded in the WebBrowser.

我用得到的文件

对象DOC = this._browser.Document; ,我可以看到它是一个 mshtml.MSHTMLDocument 和我要投它,因为这类型的,这样我可以拉的称号了,但是我无法找到这种类型的任何.NET库。

object doc = this._browser.Document; and I can see that it is an mshtml.MSHTMLDocument and I want to cast it as this type so that I can pull the title out, however I can't find this type in any .NET library.

请问我要创建的类型我或者我只是在错误的地点/处理这个错误的方式?

Will I have to create the type myself or am I just looking in the wrong place/approaching this wrong way?

我怎么能拉页标题了 System.Windows.Controls.WebBrowser 文档?

How can I pull the page title out of a System.Windows.Controls.WebBrowser Document?

推荐答案

无论是添加引用 Microsoft.mshtml 然后:

var title = (webBrowser.Document as mshtml.HTMLDocument).title;

dynamic doc = webBrowser.Document;
var title = doc.title;

这篇关于我怎么投了System.Windows.Control WebBrowser.Document到mshtml.MSHTMLDocumentClass?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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