As some of you may have already figured out depending on how you close a window in a window workspace you will get two different results. If you call Close(smartpart) on the workspace the smart gets removed from the form before it is disposed (this happens in the OnClose method). If you just click the “X” on the form the view is allowed to be disposed. To correct this I had the private method WindowFormClosed call the OnClose by changing to read the below:
private void WindowFormClosed(object sender, WorkspaceEventArgs e) { Control smartPart = e.SmartPart as Control;
if (smartPart != null) OnClose(smartPart); }
And then changed the OnClose to read:
/// <summary> /// Closes the form where the smart part is being shown. /// </summary> protected override void OnClose(Control smartPart) { Form form = windowDictionary[smartPart]; smartPart.Disposed -= ControlDisposed;
// Remove the smartPart from the form to avoid disposing it. form.Controls.Remove(smartPart);
form.Close(); windowDictionary.Remove(smartPart); base.InnerSmartParts.Remove(smartPart);
base.RaiseSmartPartClosed(smartPart); }
Remember Me
Powered by: newtelligence dasBlog 2.1.8102.813
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.
E-mail
Theme design by Jelle Druyts