Get all child panels

2 posts, 0 answers
  1. stealthsid
    stealthsid avatar
    21 posts
    Member since:
    Oct 2006

    Posted 08 Jul 2008 Link to this post

    I am trying to persist the layout of all panels to disk whenever they are closed. I'm running into a few issues (which may be moot if there is an easy way/pattern to persist to disk which I just overlooked).

    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)

       if (AfterClosed != null)
        AfterClosed(sender, e);

      private void SaveAllChildren(ControlCollection controls)
       foreach (Control c in 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();

    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,

  2. Julian Benkov
    Julian Benkov avatar
    1135 posts

    Posted 11 Jul 2008 Link to this post

    Hi Sid,

    The DockSite collection of ManagedDockables returns only its hosted IDockable windows. In your case you must use the DockingManager's GetManagedDockables() method to return all IDockable windows from its DockingSites and AutoHide container.

    In your case, only enumeration of DockingManagers is needed.

    I hope this was helpful. If you have additional questions, please contact us back.

    All the best,
    Julian Benkov
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
Back to Top