I have previously submitted this issue for discussion
; however, after seeing issues
, this seems to be a recurring problem.
Please see attached for a test code sample.
The problem can be recreated as follows:
- Run code and click on to "Tab 2" in the TabControl;
- Undock the "Sample Tool Pane" either by selecting "Float" from the dropdown menu or by dragging it out of the DockingManager;
- Close the floating window (do not re-dock it first);
- Click on to "Tab 1" and then immediately back to "Tab 2";
- Click on the "Show Sample Tool Pane" button.
This will bring up an InvalidOperationException when it hits anchorable.Show() in the code-behind with the message "Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed".
A few things confuse me here:
- I thought LayoutAnchorables could only be "hidden" rather than properly closed;
- If you repeat the above steps, but leave out step 4 (the switch between the two tabs), then everything works fine and the floating window reappears;
- If you repeat the above steps, but re-dock the floating window before you close it (at step 3), or don't undock it in the first place, then everything works fine and the "Sample Tool Pane" reappears in its docked location.