I have a DockPanel which contains a user control with its own DockingManager and DockPanels. In an ealier thread (and based on my experience) I know that the Closed event does not get called on the subordinate DockPanels. That's ok, I can work around that.
The problem I have now is that *I'm* trying to call a method on all subordinate DockPanels and I cannot find them all. Here's what I'm doing:
//This part is called on the parent DockPanel,
//which is subclassed to support the "Save" method to persist to disk
private void SubClassedDockPanel_Closed(object sender, EventArgs e)
{
this.Save();
this.SaveAllChildren(this.Controls);
if (AfterClosed != null)
{
AfterClosed(sender, e);
}
}
private void SaveAllChildren(ControlCollection controls)
{
foreach (Control c in controls)
{
SaveAllChildren(c.Controls);
if (c as IDockManager != null)
{
IDockManager dManager = c as IDockManager;
foreach (IDockingSite site in dManager.DockingSites)
{
foreach (IDockable panel in site.ManagedDockables)
{
if (panel as SubClassedDockPanel != null)
{
(panel as SubClassedDockPanel).Save();
}
}
}
return;
}
}
}
basically I look for any DockingManagers in the parent DockPanel's controls and then iterate over all of their ManagedDockables in all the DockingSites. This works with the exception of when I AutoHide a child DockPanel.
There are a few difficulties I've encountered regarding "AutoHide". First is that it causes the Closed event to fire on the child panel that is being unpinned. I'd like to understand why this is happening, and (leading into my second difficulty) where does it go? The algorithm above will not find the autohidden DockPanel.
Any assistance is greatly appreciated, I know I've posted a few questions today,
Sid