
Hello,
I know that in certain scenarios in Docking, a Dispatcher.BeginInvoke is required within our logic. For instance, when trying to move focus within a docking window after a layout change, we have to BeginInvoke because the element has to be Loaded prior to setting focus.
Since you are loading a layout and then immediately opening a modal dialog, I put several breakpoints in our code to see if something with BeginInvoke is occurring. I didn't notice any of our breakpoints being hit. But since the scenario you describe only seems to happen some of the time and not all (I saw the same), I wonder if it's something in core Win32 Windows where one window just happens to open before the other. If it was something in our code causing this, I would expect the problem to always consistently happen in the same scenario, which isn't the case here.
I tried wrapping the ShowDialog code in your updated sample like this and it seemed to prevent the issue:
// (Your code to load the DockSite layout here)
// Open the modal dialog
this.Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action)(() => {
var w = new SubWindow(() => ToolWindow1.IsFloating = true) { Owner = this };
w.ShowDialog();
}));