Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I am trying to implement a browser-like little application that would allow me to modify the viewed web-sites appearance (e.g. make the font for links bigger). It is designed for Microsoft Surface, to be used on a huge touchscreen. It uses WPF for the UI.

I am intending to use a WebBrowser control for this task. However there are two classes called WebBrowser in the docs. One of them is in System.Windows.Forms, the other in System.Windows.Controls. The first one gives access to DOM model, but is intended for Forms applications (if I understand correctly, that's definitely not what I have). The second one is added by default if you add the controller in xaml, but it gives no access to the DOM.

So, how do I access the DOM model from a WebBrowser for Surface? I am very new to c# and Microsoft technologies, so I apologise if my question is unclear or obvious.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
119 views
Welcome To Ask or Share your Answers For Others

1 Answer

For the System.Windows.Controls.WebBrowser class you can use the Document property. Add mshtml reference to your project that should be available by right click on project and selecting Add Reference, then you should be able to cast it to mshtml.IHTMLDocument2

mshtml.IHTMLDocument2 htmlDoc = webBrowser.Document as mshtml.IHTMLDocument2;
// do something like find button and click
htmlDoc.all.item("testBtn").click(); 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...