Adding Components as Child to another Component

My goal is to add components (which also have children) to a main component as children, so that when the main component is moved in the layout, they all move with it. Unfortunately this doesn’t work with root components. Is there another way how one can do this? Attach is not sufficient in my case.

foreach (var child in app.World.Components)
{
    if (child != main)
    {                    
        child.RootNode.AttachTo(main.RootNode);
    }                
}
2 Likes