The fix above only deals closing the window from the ui. But if you call Close() on the DocumentContent hosted in the floating window it still doesn't work.
The problem is in DocumentContent.InternalClose() - where it is only checking for the parentPane to be a DocumentPane.
I tried a quick fix by getting the container pane as a FloatingDockablePane, and call .Items.Remove(this).
This works, but leaves the floating window open if there are no more managedcontent to display.
The second problem happens if you explicitly call Close() on the FloatingDockablePane. This calls the DockablaPane.Close() method where it tries to cast the selected item as a DockableContent, which renders it null when the calls reach the DockingManager.Hide(DockableContent
So the entire issue gets fixed with this in the InternalClose()
FloatingDockablePane floatingParentPane = ContainerPane as FloatingDockablePane;
if (floatingParentPane != null)
However this presents other problems, ie why is the DocumentContent having to close a floating window?
What would be the logical way to do this given your current design?