I am creating a wpf application where I am using a webbrowser control. anyways sometimes I am required to look for html elements, invoke clicks, and other basic functionality.
In winforms webbrowser control I am able to achieve this by doing:
webBrowser1.Document.GetElementById("someId").SetAttribute("value", "I change the value");
In wpf webbrowser control I managed to achieve the same thing by doing:
dynamic d = webBrowser1.Document;
var el = d.GetElementById("someId").SetAttribute("value", "I change the value");
I also managed to invoke a click in the wpf webbrowser control by using the dynamic type. Sometimes I get exeptions though.
How will I be able to look for html elements, set attributes and invoke clicks in a wpf webbrowser control without having to use dynamic types where I often get exceptions? I will like to replace my winforms webbrowser control in my wpf application by a wpf webbrowser control.
Best Answer
Use the following namespace that way you can get to all element properties and eventhandler properties:
in constructor or xaml set your LoadComplete event:
then in that method create your new webbrowser document object and view the available properties and create new events as follows: