Absolute Docking

Jul 16, 2008 at 2:08 AM
Hi Adospace, I was wondering how I would go about docking content absolutely to the left/right/top/bottom.  I've setup some DockablePanes anchored to the left/right/top/bottom around a DocumentPane.  But setting a particular content to one of those panes does not seem to appear corretly.  They all seem to end up in the same pane, or the pane does not appear when new content is added to it.  Still working on it, but I was wondering if you had some thoughts.  Because I'm very use to the Weifenluo docking system which is a bit easier when it comes to docking content.  You can take the equivalant of a DockableContent, without having to mess with panes, and just tell the manager left, right, top, bottom, document, and it will create any nessisary panes required to get the content to display in one of those absolute locations.

FYI, I'm doing this all proceedurally via code because the display location of the content is configurable by the user.

Also some unoffical bug reports I have:
* Sometimes splitters don't appear between panels, not sure exactly what causes this yet.
* Sometimes clicking on a pane does not seem to allow me to focus it, I have to drag it out (with the tab, not the header because it isn't accepting focus) and dock it elsewere to get focus on it.
* When dragging windows around, if you drag near a border and move too fast focus can jump around when moving over other windows.
Jul 16, 2008 at 3:25 AM
Edited Jul 16, 2008 at 3:51 AM
Also, a feature a request I have that some of the other docking libraries have, after dragging a window out of a pane you can double click the header to re-insert it back where it was last.
Jul 16, 2008 at 6:46 PM
Hi Nick, maybe you can post the code you use to add dockable contents to panes. I suppose is somethings like this:

DockableContent cnt = new DockableContent();
cnt.Content = new TextBox();
_leftPane.Items.Add(cnt);

To emulate the Weifenluo docking system try to use a usercontrol:
1) Create a new usercontrol in VS.
2) Change the base class from UserControl to DockableContent.
3) Use VS designer to arrange controls within the DockableContent. (you can imagine the usercontrol as a different window)
4) Import the control in the main form thorugh the VS designer or directly by code:
        _leftPane.Items.Add(new MyUserControl());
    or
        _dockManager.Anchor(new MyUserControl(), AnchorStyle.Left);

Thanks for the bugs report. Probably I correct some bugs in my internal version, anyway if you find a procedure I can follow to get them let me know.
Regarding the feature, you'll find it in next release.
Jul 17, 2008 at 12:26 AM
Hey man,

_dockManager.Anchor(new MyUserControl(), AnchorStyle.Left);

Isn't possible with the current release.

But I am doing:
_leftPane.Items.Add(new MyUserControl());

already with no luck.

What is the proper way to setup these panes and the dockmanager procedurally to insure they are docked to the right area?

// inside a class derived from DockManager
{
Content = m_documentPane;

Anchor(m_leftPane, AnchorStyle.Left);
Anchor(m_rightPane, AnchorStyle.Right);
Anchor(m_topPane, AnchorStyle.Top);
Anchor(m_bottomPane, AnchorStyle.Bottom);
}

Then i do:

m_leftPane.Items.Add(dockable_content);

Based on which pane the content is being added to.  But either nothing appears, or they all show up in one pane.
Jul 18, 2008 at 9:17 AM
Yes dockManager.Anchor(new MyUserControl(), AnchorStyle.Left) is not possible with this public release but if you have a DockingManager-derived class
just add a method like this:

public Anchor(DockabelContent cnt, AnchorStyle anchorStyle)
{
    DockablePane newPane = new DockablePane();
    ResizingPanel.SetResizeWidth(newPane, 200);
    ResizingPanel.SetResizeHeight(newPane, 200);

    newPane.Items.Add(cnt);
    Anchor(newPane, _anchorStyle);
}

Anyway I need more informations on your code.
Have you provided resizingwitdth/heights for left/right etc.. panes?

Jul 19, 2008 at 3:50 PM
Yes, all the panes are initialized as:

m_leftPane = new DockablePane();
m_leftPane.SetValue(ResizingPanel.ResizeWidthProperty, 200.0);
m_leftPane.SetValue(ResizingPanel.ResizeHeightProperty, 200.0);

There's really not a whole lot to the code.  That's the initialization, and then there is a method that calls:

Items.Add() on the correct pane based on an enum.