As a rule, in WPF you do not need to create your own controls IDisposable. Unlike Windows Forms, WPF objects are UIElementfully managed, rather than (usually) wrapping their own descriptors. Thus, they do not need to be deleted, and they can be left in the garbage collector.
That is why it UserControldoes not implement IDisposable.
There are, of course, exceptions. If your class encapsulates everything that comes from HwndHost(e.g. WebBrowser), for example, you will most likely want to make your own class IDisposableto call Dispose()on the encapsulated control. This is usually only required in interop scripts (i.e. WebBrowser, which interacts with the browser’s own controls).
source
share