This project is read-only.

[Version 2.0] Move Control between multiple DockingManagers (Reusing same control)

May 31, 2013 at 12:28 AM
I have an application with two docking managers.
First I am adding Control1 is added to the dockingManager1 . At a later time I want to move Control1 from dockingManager1 to dockingManager2 . I can't figure out how. I get the exception
Specified element is already the logical child of another element. Disconnect it first
My Code for adding initially is -
layoutAnchorable = new LayoutAnchorable() { ContentId = "Help", Title = "Help", Content = Control1, };
layoutAnchorable.AddToLayout(dockingManager1, AnchorableShowStrategy.Top);

To move later I tried -
layoutAnchorable.Close();
layoutAnchorable.Content = null;

LayoutAnchorable newLayoutAnchorable = new LayoutAnchorable() { ContentId="Help", Title = "Help", Content = Control1 };
newLayoutAnchorable.AddToLayout(dockingManager2, AnchorableShowStrategy.Top);
Whatever I do - it gives the same exception. Note: I want to use the same control - not create a new instance. What do I have to do - to have the control removed from dockingManager1 's dependency tree completely.

thanks,
V
May 31, 2013 at 10:32 AM
I can't test it here, but I would guess its something like:

dockingManager1.Items.Remove(layoutAnchorable);
dockingManager2.Items.Add(layoutAnchorable);
May 31, 2013 at 1:13 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
May 31, 2013 at 7:48 PM
That is what I though - but dockingManager does not seem to have an obvious location where all the layoutAnchorables are located.
At least in 2.0 there is no dockingManager1.Items collection.

Even after closing the layout and setting content to null - there is a dependency link remaining between the dockingManager and the control. Also the existing parent of the control is still the docking manager. I cannot find where to disconnect this link. That is the problem.
thanks
Jun 3, 2013 at 3:59 PM
I have added a followup on this in the issue.