WPF WebBrowser: How to set element click event?

Posted by Ralph on Stack Overflow See other posts from Stack Overflow or by Ralph
Published on 2011-01-14T08:38:29Z Indexed on 2011/01/16 11:53 UTC
Read the original article Hit count: 395

Filed under:
|

I've figured out how to make everything red as soon as the page is finished loading:

private void webBrowser1_LoadCompleted(object sender, NavigationEventArgs e)
{
    var doc = (IHTMLDocument2)webBrowser1.Document;
    foreach (IHTMLElement elem in doc.all)
    {
        elem.style.backgroundColor = "#ff0000";
    }
}

Now what if I want to make the element only change color when it's clicked? I see that elem has an onclick property, but it's type is dynamic so I don't know what to do with it. The documentation is pretty useless.

© Stack Overflow or respective owner

Related posts about wpf

Related posts about wpf-controls