How do I ensure view models are properly disposed of if they reference unmanaged resources or have event handlers such as handling elapsed on a dispatcher timer. In the first case, a finaliser is an option, although not ideal, but in the latter, it will never be called. How can we tell when there is no longer a view attached to the view model.
Share
One possible, although not perfect solution:
Implement IDisposable on the View Model, then use this extension method in the constructor of the view.