stride3d/stride · error · NotSupportedException
Can't change the name of a UILibrary object.
Error message
Can't change the name of a UILibrary object.
What it means
This error is declared in the documentation of UILibraryRootViewModel to indicate that the name of a UILibrary asset object is immutable through this view model. Attempting to rename a UILibrary via the UI library editor's view model raises this error because the asset's identity is fixed; name changes are not a supported operation on the root of a UI library.
Solutions
- Rename the underlying asset instead (the asset's name, not the root view model's Name).
- Make the Name field read-only in the UI for the library root (disable the rename command / use IsEditable=false).
- Skip root nodes when batch-renaming hierarchy items.
Example fix
// before libraryRootViewModel.Name = "MyLibrary"; // after libraryRootViewModel.Asset.Asset.Name = "MyLibrary"; // rename the asset, not the root node
Defensive patterns
Strategy: type-guard
Validate before calling
bool canRename = !(node is UILibraryRootViewModel);
Type guard
static bool IsRenamable(IAssetNodeViewModel node) => !(node is UILibraryRootViewModel);
Try / catch
try { node.Name = newName; } catch (NotSupportedException ex) { /* rename the asset instead */ } Prevention
- Disable rename UI for library root nodes.
- Rename the asset object, never the root view model's Name.
- In bulk rename scripts, skip root view models.
When it happens
Trigger: Assigning to Name on the root view model of a UI library editor, e.g. binding a name text box TwoWay to the root node's Name, or calling rename on the library root in the scene/editor tree.
Common situations: Renaming the library via the editor tree's rename command; a generic property grid that exposes Name as editable for all hierarchy nodes; automated tests setting Name on every node.
Related errors
- Can't change the name of a UIPage object.
- The corresponding UI Element could not be found in the…
- The corresponding UI element could not be found in the…
- The given source panel is not a root element of this asset.
- Custom strides is not supported with packed PixelFormats
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/b78d416c04e249fc.
Report an issue: GitHub.
Appendix: source
Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/UILibraryEditor/ViewModels/UILibraryRootViewModel.cs:26
using Stride.Core.Extensions;
using Stride.Assets.Presentation.AssetEditors.UIEditor.ViewModels;
using Stride.Assets.Presentation.ViewModel;
using Stride.Assets.UI;
using Stride.UI;
namespace Stride.Assets.Presentation.AssetEditors.UILibraryEditor.ViewModels
{
public sealed class UILibraryRootViewModel : UIRootViewModel
{
public UILibraryRootViewModel(UIEditorBaseViewModel editor, [NotNull] UILibraryViewModel asset, IEnumerable<UIElementDesign> rootElements)
: base(editor, asset, rootElements)
{
NotifyGameSidePartAdded().Forget();
}
/// <inheritdoc />
[NotNull]
public override string Name { get => "UI Library"; set => throw new NotSupportedException("Can't change the name of a UILibrary object."); }
/// <inheritdoc />
public override void ReplaceRootElement(PanelViewModel sourcePanel, AssetCompositeHierarchyData<UIElementDesign, UIElement> hierarchy, Guid targetPanelId)
{
if (sourcePanel == null) throw new ArgumentNullException(nameof(sourcePanel));
var index = Asset.Asset.Hierarchy.RootParts.IndexOf(x => x.Id == sourcePanel.Id.ObjectId);
if (index < 0)
throw new ArgumentException(@"The given source panel is not a root element of this asset.", nameof(sourcePanel));
Asset.AssetHierarchyPropertyGraph.RemovePartFromAsset(sourcePanel.UIElementDesign);
Asset.AssetHierarchyPropertyGraph.AddPartToAsset(hierarchy.Parts, hierarchy.Parts[targetPanelId], null, index);
}
/// <inheritdoc />
protected override bool CanAddOrInsertChildren(IReadOnlyCollection<object> children, ref string message)
{
return true;
}View on GitHub (pinned to 96fad776d2)