本文介绍了Webbrowser不会自行处置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建WPF应用程序。我创建了一个用户控件,并放置了后退按钮和Web浏览器。该Web浏览器用于显示一些Flash对象,并且可以正常工作。但是,当我单击返回时,程序将返回到以前的用户控件,但是我仍然可以听到来自Webbrowser的声音。这是我的方法:

I am creating a WPF application. I created a usercontrol and put a back button and webbrowser. The webbrowser is for showing some Flash objects and works without a problem. However, when I click back, the program returns to previous user control but I can still hear some sound coming from webbrowser. Here is my method:

void btnClose_Click(object sender, RoutedEventArgs e)
{
    Content contentPage = new Content();
    webBrowser1.Dispose();
    this.Content = contentPage;
}

如何处置Web浏览器?预先感谢

How can I dispose webbrowser? Thanks in advance

推荐答案

而不是调用Dispose,您应该重置属性:

Instead of calling Dispose, you should reset the WebBrowser.Source property:

webBrowser1.Source = null;

说:

这篇关于Webbrowser不会自行处置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 10:20