{"record":{"id":"73e9238497355a1d","repo":"stride3d/stride","slug":"the-given-childpart-gettype-name-name-childpart-name-is-not","errorCode":null,"errorMessage":"The given {childPart.GetType().Name} (Name={childPart.Name}) is not the current content of {nameof(ContentControl)} (Name={control.Name}).","messagePattern":"The given (.+?) \\(Name=(.+?)\\) is not the current content of (.+?) \\(Name=(.+?)\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/engine/Stride.Assets/Quantum/UIAssetPropertyGraph.cs","lineNumber":89,"sourceCode":"                var node = Container.NodeContainer.GetOrCreateNode(panel)[nameof(Panel.Children)].Target;\n                if (index < 0)\n                    node.Add(childPart);\n                else\n                    node.Add(childPart, new NodeIndex(index));\n                return;\n            }\n            throw new NotSupportedException();\n        }\n\n        /// <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","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/engine/Stride.Assets/Quantum/UIAssetPropertyGraph.cs#L71-L107","documentation":"When detaching a child from a ContentControl in UIAssetPropertyGraph.RemoveChildPartFromParentPart, the code verifies the given childPart is exactly the object currently stored in the Content Quantum node. If it is not the current content, the removal is invalid and InvalidOperationException is thrown.","triggerScenarios":"Calling RemoveChildPartToParentPart (RemoveChildPartFromParentPart) with a child that is not the ContentControl's current Content — e.g. the child was already replaced, or a stale/duplicate part instance is passed.","commonSituations":"Undo/redo desynchronization where the editor holds an old child reference, deleting a control that was already swapped out, or asset corruption leaving Quantum nodes pointing at replaced instances.","solutions":["Pass the actual current Content child when removing (read Content first)","Reload the UI asset to resynchronize editor state with the Quantum container","If the child was already removed, skip the removal instead of calling again","Recreate the UI hierarchy if node state is corrupted"],"exampleFix":"// before\nvar stale = oldImage;\ngraph.RemoveChildPartFromParentPart(contentControl, stale); // not current content\n// after\nvar current = (UIElement)contentControl.Content;\ngraph.RemoveChildPartFromParentPart(contentControl, current);","handlingStrategy":"type-guard","validationCode":"var node = Container.NodeContainer.GetOrCreateNode(control)[nameof(ContentControl.Content)];\nif (childPart != node.Retrieve()) { /* re-fetch current content before removing */ }","typeGuard":"bool isCurrentContent(UIElement parent, UIElement child) =>\n    parent is ContentControl c &&\n    ReferenceEquals(child, Container.NodeContainer.GetOrCreateNode(c)[nameof(ContentControl.Content)].Retrieve());","tryCatchPattern":"try\n{\n    graph.RemoveChildPartFromParentPart(parent, child);\n}\ncatch (InvalidOperationException)\n{\n    // child is stale: re-read Content and remove the actual current child\n}","preventionTips":["Always fetch the current Content reference immediately before removal","Guard undo/redo code against operating on stale part instances","Reload the UI asset when editor state and runtime state diverge","Skip removal calls for children already known to be detached"],"tags":["ui","quantum","invalid-state"],"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-15T23:17:13.987Z"}