{"record":{"id":"b9510fa845df211b","repo":"stride3d/stride","slug":"changing-the-panel-from-a-user-library-type-is-currently-not","errorCode":null,"errorMessage":"Changing the panel from a user library type is currently not supported.","messagePattern":"Changing the panel from a user library type is currently not supported\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"warning","filePath":"sources/editor/Stride.Assets.Presentation/AssetEditors/UIEditor/ViewModels/PanelViewModel.cs","lineNumber":243,"sourceCode":"        {\n            var assetPanel = (Panel)elementDesign.UIElement;\n\n            foreach (var child in assetPanel.Children)\n            {\n                if (!asset.Hierarchy.Parts.TryGetValue(child.Id, out UIElementDesign childDesign))\n                {\n                    childDesign = new UIElementDesign(child);\n                }\n                if (child != childDesign.UIElement) throw new InvalidOperationException();\n                yield return childDesign;\n            }\n        }\n\n        private void ChangeLayoutType([NotNull] IUIElementFactory factory)\n        {\n            var targetType = (factory as UIElementFromSystemLibrary)?.Type;\n            if (targetType == null)\n                throw new NotSupportedException(\"Changing the panel from a user library type is currently not supported.\");\n            if (!typeof(Panel).IsAssignableFrom(targetType))\n                throw new ArgumentException(@\"The target type is not a panel\", nameof(targetType));\n\n            // If the target panel type is the same as the current panel type, do nothing\n            if (targetType == ElementType)\n                return;\n\n            using (var transaction = Editor.UndoRedoService.CreateTransaction())\n            {\n                Panel targetPanel = null;\n                // Try to maintain the layout order depending on the combinaison of currentType/targetType.\n                //\n                // Notes:\n                // - from any panel to a Canvas (tricky case)\n                //    - for now don't do anything smart\n                //        + later we could try to calculate Canvas absolute or relative position so that elements appear at the same position\n                var stackPanel = AssetSidePanel as StackPanel;\n                if (stackPanel != null)","sourceCodeStart":225,"sourceCodeEnd":261,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/editor/Stride.Assets.Presentation/AssetEditors/UIEditor/ViewModels/PanelViewModel.cs#L225-L261","documentation":"PanelViewModel.ChangeLayoutType converts a panel to another panel type, but only factories producing system-library types (UIElementFromSystemLibrary) are supported. If the factory comes from a user (custom) library, the resolved target Type is null and NotSupportedException is thrown — converting to user library panels is not implemented.","triggerScenarios":"Invoking ChangeLayoutType with an IUIElementFactory that is not UIElementFromSystemLibrary, typically via a context-menu 'change layout' action listing user-defined panel types from a custom library.","commonSituations":"Projects with custom UI element libraries where users right-click a panel and pick one of those custom types to convert to; editor extensions enumerating all registered factories including user ones.","solutions":["Filter the change-layout menu to system-library panel factories only.","Choose a built-in panel type (Grid, StackPanel, Canvas) as the conversion target.","Disable the conversion command when the factory is not UIElementFromSystemLibrary.","Implement user-type conversion support in ChangeLayoutType if the feature is required."],"exampleFix":"// before\npanelViewModel.ChangeLayoutType(customLibraryFactory); // throws\n// after\nif (customLibraryFactory is UIElementFromSystemLibrary)\n    panelViewModel.ChangeLayoutType(customLibraryFactory);\nelse\n    logger.Warning(\"Converting to user library panel types is not supported.\");\n","handlingStrategy":"type-guard","validationCode":"if (!(factory is UIElementFromSystemLibrary)) { /* hide/disable change-layout option */ return; }","typeGuard":"bool IsSystemLibraryFactory(IUIElementFactory factory) => factory is UIElementFromSystemLibrary sys && typeof(Panel).IsAssignableFrom(sys.Type);","tryCatchPattern":"try { panel.ChangeLayoutType(factory); }\ncatch (NotSupportedException ex) when (ex.Message.Contains(\"user library type\")) {\n    // surface a message: only built-in panel types can be converted to\n}","preventionTips":["Filter conversion menus to UIElementFromSystemLibrary factories.","Only offer built-in panel types as conversion targets.","Guard the command's CanExecute against factory type.","Check typeof(Panel).IsAssignableFrom(targetType) before invoking."],"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"}