stride3d/stride · error · InvalidOperationException
The given (Name= ) is not the current content of (Name= ).
Error message
The given {childPart.GetType().Name} (Name={childPart.Name}) is not the current content of {nameof(ContentControl)} (Name={control.Name}). What it means
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.
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
Example fix
// before var stale = oldImage; graph.RemoveChildPartFromParentPart(contentControl, stale); // not current content // after var current = (UIElement)contentControl.Content; graph.RemoveChildPartFromParentPart(contentControl, current);
Defensive patterns
Strategy: type-guard
Validate before calling
var node = Container.NodeContainer.GetOrCreateNode(control)[nameof(ContentControl.Content)];
if (childPart != node.Retrieve()) { /* re-fetch current content before removing */ } Type guard
bool isCurrentContent(UIElement parent, UIElement child) =>
parent is ContentControl c &&
ReferenceEquals(child, Container.NodeContainer.GetOrCreateNode(c)[nameof(ContentControl.Content)].Retrieve()); Try / catch
try
{
graph.RemoveChildPartFromParentPart(parent, child);
}
catch (InvalidOperationException)
{
// child is stale: re-read Content and remove the actual current child
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: "Invalid state transition" errors: "status must be X, actually Y", "already rejected/charging/uninstalled", "cannot ... while running" — what they mean when a library rejects your call — this error's family across 31 libraries.
Related errors
- (Name= ) already has a content.
- Could not find asset
- Expect name1=value1;name2=value2 format.
- The routed event cannot be changed while the event is being…
- Can only assign UIElementService to the root element!
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/73e9238497355a1d.
Report an issue: GitHub.
Appendix: source
Thrown at sources/engine/Stride.Assets/Quantum/UIAssetPropertyGraph.cs:89
var node = Container.NodeContainer.GetOrCreateNode(panel)[nameof(Panel.Children)].Target;
if (index < 0)
node.Add(childPart);
else
node.Add(childPart, new NodeIndex(index));
return;
}
throw new NotSupportedException();
}
/// <inheritdoc/>
protected override void RemoveChildPartFromParentPart(UIElement parentPart, UIElement childPart)
{
var control = parentPart as ContentControl;
if (control != null)
{
var node = Container.NodeContainer.GetOrCreateNode(control)[nameof(ContentControl.Content)];
if (childPart != node.Retrieve())
throw new InvalidOperationException($"The given {childPart.GetType().Name} (Name={childPart.Name}) is not the current content of {nameof(ContentControl)} (Name={control.Name}).");
node.Update(null);
return;
}
var panel = parentPart as Panel;
if (panel != null)
{
var index = panel.Children.IndexOf(childPart);
if (index == -1)
throw new InvalidOperationException($"The given {childPart.GetType().Name} (Name={childPart.Name}) is not a child of {nameof(Panel)} (Name={panel.Name}).");
var node = Container.NodeContainer.GetOrCreateNode(panel)[nameof(Panel.Children)].Target;
node.Remove(childPart, new NodeIndex(index));
return;
}
throw new NotSupportedException();
}
View on GitHub (pinned to 96fad776d2)