C#/WPF:与 Web 浏览器控件交互? [英] C#/WPF: interaction with web browser control?

查看:43
本文介绍了C#/WPF:与 Web 浏览器控件交互?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以通过使用 WPF 浏览器控件与本地或远程页面的源代码实时交互.

Is it possible to interact with the source code of a local or remote page in real time through the use of the WPF browser control.

我的意思的一个简单示例是,用户可以单击一个按钮,将所选文本加粗.有点像 WYSIWYG HTML 编辑器,但使用浏览器控件.

A simple example of what I mean would be where the user can click a button that will bold the selected text. Sort of like a WYSIWYG HTML editor but using the browser control.

有没有一种方法可以像使用 JavaScript 那样与源代码交互.是否需要设置一个系统来解析选中的网页,然后修改其代码,然后在浏览器控件中重新打开新代码来模拟实时编辑的体验?

Is there a way to interact with the source code like this with the same power you have with JavaScript. Would one have to set up a system to parse the selected web page and then modify its code and then reopen the new code in the browser control to simulate the experience of real time editing?

谢谢

推荐答案

您可以通过 webbrowser 控件完全访问 DOM,所以答案是肯定的.但是,webbrowser 控件不是 wpf 控件而是 winforms 控件,要使用它,您必须使用 wpf winforms 容器控件.

You have full DOM access through the webbrowser control, so the answer is yes. However, the webbrowser control is not a wpf control but a winforms control, and in order to use it you would have to use the wpf winforms container control.

这篇关于C#/WPF:与 Web 浏览器控件交互?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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