Element already has a logical parent. It must be detached from the old parent before it is attached

Docking/MDI for WPF Forum

Posted 7 years ago by keshav bansal
Version: 12.1.0562
Avatar

Hi,

How to remove exception like Element already has a logical parent. It must be detached from the old parent before it is attached to a new one.

For Example

ToolWindowContainer con = newToolWindowContainer();

con.Items.Add(toolWindow);

BaseDocksite.AutoHideLeftContainers.Add(con);

 

toolwindow that i want to add in the con(ToolwindowContainer) is attached with the Logical parent that  is its container.

 

If i reterieve the container using

ToolWindowContainer ablContainer = toolWindow.Parent asToolWindowContainer;

and then close this container using

ablContainer.Close();

con.Items.Add(toolWindow);

BaseDocksite.AutoHideLeftContainers.Add(con);

its working fine.

But I  don't want to close this container attached with the toolwindow.

So how to solve this problem without closing  this container attached with the toolwindow.

[Modified 7 years ago]

Comments (1)

Posted 7 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar

H Keshav,

You should never be programmatically creating a ToolWindowContainer or other kind of container with our docking system. The only place you should ever manually define a container is if your make your initial layout in XAML. Instead of programmatically creating containers, please use the various methods on the tool window such as Dock methods and others described in the documentation for programmatic docking.  That should solve the problem.


Actipro Software Support

The latest build of this product (v2019.1 build 0681) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.