Hi Ian,
We aren't experts in Prism so please bear with us and help provide any insight you have.
What's happening is that when the drop occurs on the linked DockSite, the DockSiteRegionBehavior.OnDockSiteWindowUnregistered method executes and clears the container bindings. That is to be expected.
1) A first question is, should the DockSiteRegionBehavior be removing the view model from the region here? Right now we don't do that, and that's why you see that a closed document's view model is still listed in the region. Would this code be appropriate at the end of that method?
// Ensure the view is removed from the region
var region = this.Region;
if (region != null) {
if (region.Views.Contains(e.Window))
region.Remove(e.Window);
else if (region.Views.Contains(e.Window.DataContext))
region.Remove(e.Window.DataContext);
}
2) The next issue is that in the OnDockSiteWindowRegistered method above it, the IsDockingWindowAValidContainer check returns false and it quits out without restoring container bindings. This causes the empty tab title, etc. The reason that returns false is that when we assign the new DockSite, we see if the view model can be added to the new DockSite's DocumentItemsSource. In this scenario, the DockSite.DocumentItemsSource is a read-only collection, and thus the document window falls back to being added normally, without being flagged as a container generated by an items source. To sum up, the problem here is that the document window is transferring as a non-container.
3) It seems like OnDockSiteWindowRegistered might also need some way to register the view model into the new region? Doing so would probably cause a new document window container to be generated though, instead of using the one we just dragged.
This is a bit of a pickle. The main setback is that the DocumentsItemSource we use for Prism right now is read-only and that prevents #2 from working. Which in turn I believe causes odd side effects and problems for #3.