WPF Window类的IDisposable成员 [英] IDisposable member of WPF Window class
本文介绍了WPF Window类的IDisposable成员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我将IDisposable类成员添加到Windows Forms Form类时,我将处置代码添加到Form的Dispose方法中.将IDisposable类成员添加到WID窗口类中而不是IDisposable时该怎么办?
When I add IDisposable class member to Windows Forms Form class, I add disposing code to Form's Dispose method. What should I do when I add IDisposable class member to WPF Window class, which is not IDisposable?
推荐答案
扩展您的窗口类,使其具有IDisposable,然后像以前一样实现Dispose()方法:
Extend your window class so that it has IDisposable, then implement the Dispose() method as before:
public class MyWindow : Window, IDisposable
{
public void Dispose()
{
// Dispose your objects here as before.
}
}
这篇关于WPF Window类的IDisposable成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文