What is the correct way to dispose of a WPF window?

vanja. picture vanja. · Feb 20, 2009 · Viewed 60.4k times · Source

I have a WPF window which I am creating from another window by calling Show(), then letting it Close() itself. When the window closes, I expect it to die, call its destructor, and delete all its child elements (such as timers..).

What is the correct way of invoking such an action?

Answer

Simon Buchan picture Simon Buchan · Feb 20, 2009

Close() releases all unmanaged resources, and closes all owned Windows.

Any other managed resources you need deterministic disposal of should be handled from the Closed event.

Reference

(note: deleted previous answer, it was a completely wrong guess)