C#/WPF: interaction with web browser control?

2019-08-30 05:13发布

问题:

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.

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.

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?

Thanks

回答1:

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.