简体   繁体   中英

How to clear WebBrowser control in WPF

I'm using the code from the following link: Displaying html from string in WPF WebBrowser control

It works well except when I delete the item containing the html, e.NewValue becomes null and I get an exception. Is there a way to return the WebBrowser control to a blank screen?

I found this. Anyone have anything better?

if (wb != null)
{
    if (e.NewValue != null)
        wb.NavigateToString(e.NewValue as string);
    else
        wb.Navigate("about:blank");
}

我只是将WebBrowserLabel的DocumentText设置为string.Empty

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM