WindowWorkspace suggestion

Feb 15, 2008 at 11:18 AM
Hi

I am currently working on a solution where I need to detach (Close) a smartpart from a TabWorkspace (or DeckWorkspace) and attach (Show) it to a WindowWorkspace and back.

Moving from TabWorkspace to WindowWorkspace works fine, but moving back throws an exception. The problem is that the smartpart has a parent in the logical tree when it is closed in the WindowWorkspace and therefore cannot be attached to the TabWorkspace again.

I would like to suggest that the OnClose method in the Window Workspace is changed from:


protected override void OnClose(object smartPart)
{
Debug.Assert(_windows.ContainsKey(smartPart));
_windows[smartPart].Close();
_windows.Remove(smartPart);
}

to

protected override void OnClose(object smartPart)
{
Debug.Assert(_windows.ContainsKey(smartPart));

Window window = _windows[smartPart];
window.Close();
window.Content = null;

_windows.Remove(smartPart);
}

This will detach the logical parent from the smartpart and make it possible to reattach the smartpart to the TabWorkspace. This change is consistent with how TabWorkspace works.

Regards Lau
Coordinator
Feb 25, 2008 at 6:20 PM
Thanks, this is fixed. This problem was noted in the WPF/CAB Shell source code, too, so I've fixed things there as well.

Note that this is a potentially breaking change. Dialog results are now conveyed via the WindowSmartPartInfo. If you show a dialog window, the WindowSmartPartInfo.DialogResult property will be set after.

Regards,
Kent