Thank you for your post. Your solution presumes the control is a singleton, and does not work otherwise as the caller of the function instantiates an entirely new instance. But I think I can make it work.
While I can make the UC a singleton and avoid the creation of the control the 2nd time, I am not able to delete the static instance of the user control as I cannot find a reliable event in which to do this.
I tried a variation on your code and tested the name rather than the instance, but it appears there is a different problem. Closing the control does not appear to unload it from the dock window's controls.
private void ShowLibraryMaintenance()
ucLibraryInfoBar _ucLibraryInfoBar = new ucLibraryInfoBar(_logic);
_ucLibraryInfoBar.Name = "LibraryInfoBar";
FrmLibraryMaintenance _frmLibraryMaintenance = FrmLibraryMaintenance.Instance(_logic, OnSelectedSongChanged);
_frmLibraryMaintenance.MdiParent = this;
//sets visibility of menu items based on access control
private void ShowInfoBar(UserControl libraryInfoBar)
foreach (DockWindow dockwindow in this.rdMainDock.DockWindows)
if (dockwindow.Controls.Count > 0 && dockwindow.Controls.Name == "LibraryInfoBar")
HostWindow _libHost = rdMainDock.DockControl(libraryInfoBar, DockPosition.Left);
_libHost.Text = "Library";
When I close the LibraryInfoBar and refire the ShowLibraryMaintenance method, the dockwindow.Controls.Count is still greater than 0.