{"record":{"id":"a4b4f4aa514d6a39","repo":"stride3d/stride","slug":"can-t-change-the-name-of-a-uipage-object","errorCode":null,"errorMessage":"Can't change the name of a UIPage object.","messagePattern":"Can't change the name of a UIPage object\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/UIPageEditor/ViewModels/UIPageRootViewModel.cs","lineNumber":33,"sourceCode":"\nnamespace Stride.Assets.Presentation.AssetEditors.UIPageEditor.ViewModels\n{\n    public sealed class UIPageRootViewModel : UIRootViewModel, IAddChildViewModel\n    {\n        /// <summary>\n        /// A UIPage asset cannot have more than one root.\n        /// </summary>\n        internal static readonly string OneRootOnly = \"A UIPage asset can't have more than one root.\";\n\n        public UIPageRootViewModel([NotNull] UIEditorBaseViewModel editor, [NotNull] UIPageViewModel asset, UIElementDesign rootElement)\n            : base(editor, asset, rootElement?.Yield())\n        {\n            NotifyGameSidePartAdded().Forget();\n        }\n\n        /// <inheritdoc />\n        [NotNull]\n        public override string Name { get => \"UI Page\"; set => throw new NotSupportedException(\"Can't change the name of a UIPage object.\"); }\n\n        [CanBeNull]\n        public UIElementViewModel RootElement => RootElements.SingleOrDefault();\n\n        /// <inheritdoc />\n        public override void ReplaceRootElement(PanelViewModel sourcePanel, AssetCompositeHierarchyData<UIElementDesign, UIElement> hierarchy, Guid targetPanelId)\n        {\n            if (sourcePanel == null) throw new ArgumentNullException(nameof(sourcePanel));\n            if (sourcePanel.Id.ObjectId != Asset.Asset.Hierarchy.RootParts.Single().Id)\n                throw new ArgumentException(@\"The given source panel does not match the currently set root element\", nameof(sourcePanel));\n\n            Asset.AssetHierarchyPropertyGraph.RemovePartFromAsset(sourcePanel.UIElementDesign);\n            Asset.AssetHierarchyPropertyGraph.AddPartToAsset(hierarchy.Parts, hierarchy.Parts[targetPanelId], null, Asset.Asset.Hierarchy.RootParts.Count);\n        }\n\n        /// <inheritdoc />\n        // ReSharper disable once RedundantAssignment\n        protected override bool CanAddOrInsertChildren(IReadOnlyCollection<object> children, ref string message)","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/UIPageEditor/ViewModels/UIPageRootViewModel.cs#L15-L51","documentation":"The Name setter of UIPageRootViewModel always throws NotSupportedException: the root of a UI page asset is a fixed pseudo-node labeled 'UI Page' whose display name cannot be changed through the view model.","triggerScenarios":"Assigning to Name on the UIPage root view model, e.g. a TwoWay name binding in a property grid or calling the tree rename command on the page root.","commonSituations":"Generic rename UI applied to all hierarchy nodes; scripted bulk renaming that includes root nodes; expecting the root's Name to mirror the asset name.","solutions":["Rename the UIPage asset itself rather than the root view model's Name.","Treat the page root's Name as read-only in the UI (disable rename for the root node).","Exclude root nodes from rename operations."],"exampleFix":"// before\npageRootViewModel.Name = \"MyPage\";\n// after\npageRootViewModel.Asset.Asset.Name = \"MyPage\"; // rename the asset, not the root node","handlingStrategy":"type-guard","validationCode":"bool canRename = !(node is UIPageRootViewModel);","typeGuard":"static bool IsRenamable(IAssetNodeViewModel node) => !(node is UIPageRootViewModel);","tryCatchPattern":"try { node.Name = newName; } catch (NotSupportedException ex) { /* rename the asset instead */ }","preventionTips":["Disable rename UI for the page root node.","Rename the UIPage asset itself.","Exclude root view models from bulk rename operations."],"tags":["stride","ui-page","readonly-property","notsupportedexception"],"backgroundTag":"operation-not-supported","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}