{"record":{"id":"71ed634450d110dd","repo":"stride3d/stride","slug":"the-given-childpart-gettype-name-name-childpart-name-is-not-71ed63","errorCode":null,"errorMessage":"The given {childPart.GetType().Name} (Name={childPart.Name}) is not a child of {nameof(Panel)} (Name={panel.Name}).","messagePattern":"The given (.+?) \\(Name=(.+?)\\) is not a child of (.+?) \\(Name=(.+?)\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Assets/Quantum/UIAssetPropertyGraph.cs","lineNumber":99,"sourceCode":"        /// <inheritdoc/>\n        protected override void RemoveChildPartFromParentPart(UIElement parentPart, UIElement childPart)\n        {\n            var control = parentPart as ContentControl;\n            if (control != null)\n            {\n                var node = Container.NodeContainer.GetOrCreateNode(control)[nameof(ContentControl.Content)];\n                if (childPart != node.Retrieve())\n                    throw new InvalidOperationException($\"The given {childPart.GetType().Name} (Name={childPart.Name}) is not the current content of {nameof(ContentControl)} (Name={control.Name}).\");\n\n                node.Update(null);\n                return;\n            }\n            var panel = parentPart as Panel;\n            if (panel != null)\n            {\n                var index = panel.Children.IndexOf(childPart);\n                if (index == -1)\n                    throw new InvalidOperationException($\"The given {childPart.GetType().Name} (Name={childPart.Name}) is not a child of {nameof(Panel)} (Name={panel.Name}).\");\n\n                var node = Container.NodeContainer.GetOrCreateNode(panel)[nameof(Panel.Children)].Target;\n                node.Remove(childPart, new NodeIndex(index));\n                return;\n            }\n            throw new NotSupportedException();\n        }\n\n        /// <inheritdoc/>\n        protected override Guid GetIdFromChildPart(object part)\n        {\n            return ((UIElement)part).Id;\n        }\n\n        /// <inheritdoc/>\n        protected override bool ShouldAddNewPartFromBase(AssetCompositeHierarchyPropertyGraph<UIElementDesign, UIElement> baseAssetGraph, UIElementDesign newPart, UIElement newPartParent, Guid instanceId)\n        {\n            if (!base.ShouldAddNewPartFromBase(baseAssetGraph, newPart, newPartParent, instanceId))","sourceCodeStart":81,"sourceCodeEnd":117,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Assets/Quantum/UIAssetPropertyGraph.cs#L81-L117","documentation":"Thrown by UIAssetPropertyGraph.RemoveChildPartFromParentPart when, during asset reparenting, the given part is not present in the target Panel's Children collection. The code casts the parent to Panel, calls Children.IndexOf(childPart), and throws InvalidOperationException if the index is -1, so the node graph can not be updated consistently.","triggerScenarios":"Calling RemoveChildPartFromParentPart with a parentPart that is a Panel whose Children list does not contain childPart; typically when the child was already removed, was never added to this parent, or the parent is a different panel instance than the one holding the child.","commonSituations":"Editing a UI hierarchy in Game Studio where two editors operate on stale copies; custom asset scripts that reparent elements after having already detached them; deserialized assets whose Children indices differ from the in-memory node graph.","solutions":["Verify childPart.Parent points at the same panel you pass as parentPart before removing.","Check IndexOf(childPart) >= 0 on panel.Children yourself and skip the removal if it is not found.","Reload the UI asset if the in-memory hierarchy and node graph have drifted apart."],"exampleFix":"// before\npanel.Children.Remove(child);\nparentGraph.RemoveChildPartFromParentPart(panel, child);\n\n// after\nvar index = panel.Children.IndexOf(child);\nif (index >= 0)\n{\n    panel.Children.RemoveAt(index);\n    parentGraph.RemoveChildPartFromParentPart(panel, child);\n}","handlingStrategy":"validation","validationCode":"if (parentPart is Panel panel && panel.Children.IndexOf(childPart) >= 0)\n    RemoveChildPartFromParentPart(parentPart, childPart);","typeGuard":"bool CanRemove(Part parent, Part child) => parent is Panel p && p.Children.Contains(child);","tryCatchPattern":null,"preventionTips":["Always fetch the parent via childPart.Parent instead of a cached reference.","Guard reparenting code with Contains checks."],"tags":["ui","invalid-state-transition","collection"],"backgroundTag":"invalid-state-transition","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}