Thanks again for your help on my last issue. I have a new issue where I can't seem to get my ViewModels to dispose properly when they are removed from the docking manager children collection. I did see the article on the AutomationPeer fix and have added a FakeUserControlPeer that subclasses UserControlAutomationPeer but the override does not seem to be called. I tried this at the window level with the same results.
setting the e.TargetTabItem.DataContext = null in the TabClosed event cleans up most of the anchors to the VM, but there is still a static drag drop handler that is attached. I am sure there is something I am missing or doing wrong.
I am removing the FrameworkElement from the dockingManager.Children list on line 150. I am also setting the FrameworkElement.DataContext = null (line 65) just to ensure that any command predicates are unhooked before attempting to dispose. finally, i did add a force GC collection menu item to force the GC to run. This is for testing only.
To prove that the VM will properly dispose there are 2 options to spawn a window.
1. Add Content Item - this adds a tabbed item to the docking manager. This window is not disposed until the shell closes.
2. Open New Content Window - this just opens a new window. When this window is closed, the VM properly disposes (click Garbage Collect if you don't want to wait).
When a ViewModel is disposed, you will see text to the output window in the form of:
DEBUG: ContentPageViewModel (7880838) Finalized. Priority: None. Timestamp:2016-03-24 10:51:55Z.
Please make sure that you are in debug mode or you won't see the trace output.
Thanks in advance,
P.S. the IDisposable implementation is very rudimentary and will be implemented differently in a production application. This is was put together quickly for demo purposes.