如何在WPF中清除WebBrowser控件

时间:2014-02-27 17:49:53

标签: c# wpf webbrowser-control

我使用以下链接中的代码:Displaying html from string in WPF WebBrowser control

除非我删除包含html的项目,e.NewValue变为null并且我得到一个例外,但效果很好。有没有办法将WebBrowser控件返回到空白屏幕?

2 个答案:

答案 0 :(得分:14)

我找到了这个。谁有更好的东西?

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

答案 1 :(得分:0)

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

相关问题