{"record":{"id":"c21b72de6f7a8459","repo":"stride3d/stride","slug":"grouping-elements-into-a-user-library-type-isn-t-supported","errorCode":null,"errorMessage":"Grouping elements into a user library type isn't supported.","messagePattern":"Grouping elements into a user library type isn't supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"warning","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/UIEditor/ViewModels/UIEditorBaseViewModel.cs","lineNumber":592,"sourceCode":"            CreateAssetFromSelectedParts(() => new UIPageAsset { Design = new UIAssetBase.UIDesign { Resolution = UIAsset.Design.Resolution } }, e => e?.Name ?? \"UIPage\", false, out idRemappings);\n        }\n\n        /// <summary>\n        /// Retrieves an enumeration of elements at the given UI-space position.\n        /// </summary>\n        /// <param name=\"worldPosition\"></param>\n        /// <returns></returns>\n        [MethodImpl(MethodImplOptions.AggressiveInlining)]\n        private IEnumerable<UIElementViewModel> GetElementsAtPosition(ref Vector3 worldPosition)\n        {\n            return Controller.AdornerService.GetElementIdsAtPosition(ref worldPosition).Select(id => FindPartViewModel(new AbsoluteId(Asset.Id, id))).OfType<UIElementViewModel>();\n        }\n\n        private void GroupInto(IUIElementFactory factory)\n        {\n            var targetPanelType = (factory as UIElementFromSystemLibrary)?.Type;\n            if (targetPanelType == null)\n                throw new NotSupportedException(\"Grouping elements into a user library type isn't supported.\");\n            if (!typeof(Panel).IsAssignableFrom(targetPanelType))\n                throw new ArgumentException(@\"The target type isn't a panel\", nameof(targetPanelType));\n\n            if (SelectedContent.Count == 0)\n                return;\n\n            // Ensure that the selected elements are sibling.\n            var allParents = SelectedItems.Select(x => x.Parent).OfType<UIHierarchyItemViewModel>().ToList();\n            var parent = allParents[0];\n            if (allParents.Any(x => x != parent))\n                throw new InvalidOperationException(\"This operation can only be executed on a selection of sibling elements.\");\n\n            using (var transaction = UndoRedoService.CreateTransaction())\n            {\n                var children = SelectedItems.ToList();\n                // Create the new panel into which we'll insert the selection\n                var newPanel = (Panel)Activator.CreateInstance(targetPanelType);\n                var newPanelDesign = new UIElementDesign(newPanel);","sourceCodeStart":574,"sourceCodeEnd":610,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/UIEditor/ViewModels/UIEditorBaseViewModel.cs#L574-L610","documentation":"UIEditorBaseViewModel.GroupInto wraps the selected elements into a new parent panel of the given factory's type. Only system-library panel types are supported; if the factory resolves from a user (custom) library, the target type is null and NotSupportedException is thrown, because instantiating user library types as grouping containers is not implemented.","triggerScenarios":"Executing 'group into' with an IUIElementFactory that is not UIElementFromSystemLibrary — e.g. grouping selected elements into a user-defined panel type from a custom library via the editor's group command.","commonSituations":"Users with custom UI element libraries selecting elements and choosing 'group into <custom panel>'; editor extensions exposing all factories to the grouping command.","solutions":["Restrict the group-into menu to system-library panel factories (UIElementFromSystemLibrary whose type is a Panel).","Group into a built-in panel type such as Grid or StackPanel.","Disable or hide the grouping command for user library factories.","Extend GroupInto to resolve user library types if grouping into custom panels is required."],"exampleFix":"// before\nviewModel.GroupInto(customFactory); // throws\n// after\nif (customFactory is UIElementFromSystemLibrary)\n    viewModel.GroupInto(customFactory);\nelse\n    logger.Warning(\"Grouping into user library panel types is not supported.\");\n","handlingStrategy":"type-guard","validationCode":"if (!(factory is UIElementFromSystemLibrary sys) || !typeof(Panel).IsAssignableFrom(sys.Type)) return; // unsupported grouping target","typeGuard":"bool CanGroupInto(IUIElementFactory factory) => factory is UIElementFromSystemLibrary sys && typeof(Panel).IsAssignableFrom(sys.Type);","tryCatchPattern":"try { viewModel.GroupInto(factory); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"user library type\")) {\n    // notify user: grouping supports built-in panel types only\n}","preventionTips":["Restrict group-into menus to system-library panel factories.","Use Grid/StackPanel as default grouping containers.","Guard the grouping command's CanExecute with a factory type check.","Hide user library factories from grouping UI."],"tags":["csharp","stride","ui-editor","unsupported-operation"],"backgroundTag":"unsupported-operation","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"}