I'm building an application in which I've created several WPF user controls. The user controls are essentially 'panels' that will hold content with controls around the outer edge. The XAML for the main window uses one of these user controls
and is attempting to set its content to two other user controls in a dockpanel. Basically, it's to place two smaller panels (one upper and one lower) inside a larger, outer panel. (See XAML below.)
I can place one user control inside the other without a problem. But when I add the second user control, I get the dreaded:
Specified element is already the logical child of another element. Disconnect it first.
I really don't understand why. My understanding of the error is that it comes from attempting to place the same element within the visual tree twice. An element can't have two parents. However, each of my user controls is completely separate.
Their underlying viewmodel code derives from the same base class, but each user control is separate. I'm not even trying to place two of the same kind in there at the same time. I thought at first that it might be that I had elements named identically
in the different controls, so I renamed them so that all are unique. It makes no difference.
So far as I can tell, there are not any duplicate elements anywhere,
View Complete Post