Reputation: 40150
So, I've never done a sizable WPF project before now, but this one has me wondering; What's up with WPF classes not implementing IDisposable
? By comparison, all of the UI elements in Windows Forms implement IDisposable
, to assure they get rid of the underlying handles and such.
I think the same Windows objects are under the covers there, and those resources have to be released; so, how is WPF doing that?
Is there anything I need to be doing with my WPF Window objects beyond Close()
ing them?
Upvotes: 1
Views: 2684
Reputation: 36984
WinForms controls have handles because they are wrappers around Win32 controls. WPF controls are not (well, windows are, but the controls they host are not). The reason is that, after all, a WPF window is just a Direct3D rendering context, and all controls are just a bunch of triangles. So, they don't need to be actually registered to the OS, and therefore, they don't have handles (except windows and anything that inherits from HwndHost
, of course, which are Win32 objects).
That's why there's such a sizeable interop layer between WPF and WinForms: WPF controls simply aren't Windows objects.
Upvotes: 18