stride3d/stride · warning · NotSupportedException

Changing the panel from a user library type is currently…

Error message

Changing the panel from a user library type is currently not supported.

What it means

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.

Solutions

  1. Filter the change-layout menu to system-library panel factories only.
  2. Choose a built-in panel type (Grid, StackPanel, Canvas) as the conversion target.
  3. Disable the conversion command when the factory is not UIElementFromSystemLibrary.
  4. Implement user-type conversion support in ChangeLayoutType if the feature is required.

Example fix

// before
panelViewModel.ChangeLayoutType(customLibraryFactory); // throws
// after
if (customLibraryFactory is UIElementFromSystemLibrary)
    panelViewModel.ChangeLayoutType(customLibraryFactory);
else
    logger.Warning("Converting to user library panel types is not supported.");
Defensive patterns

Strategy: type-guard

Validate before calling

if (!(factory is UIElementFromSystemLibrary)) { /* hide/disable change-layout option */ return; }

Type guard

bool IsSystemLibraryFactory(IUIElementFactory factory) => factory is UIElementFromSystemLibrary sys && typeof(Panel).IsAssignableFrom(sys.Type);

Try / catch

try { panel.ChangeLayoutType(factory); }
catch (NotSupportedException ex) when (ex.Message.Contains("user library type")) {
    // surface a message: only built-in panel types can be converted to
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/b9510fa845df211b. Report an issue: GitHub.

Appendix: source

Thrown at sources/editor/Stride.Assets.Presentation/AssetEditors/UIEditor/ViewModels/PanelViewModel.cs:243

        {
            var assetPanel = (Panel)elementDesign.UIElement;

            foreach (var child in assetPanel.Children)
            {
                if (!asset.Hierarchy.Parts.TryGetValue(child.Id, out UIElementDesign childDesign))
                {
                    childDesign = new UIElementDesign(child);
                }
                if (child != childDesign.UIElement) throw new InvalidOperationException();
                yield return childDesign;
            }
        }

        private void ChangeLayoutType([NotNull] IUIElementFactory factory)
        {
            var targetType = (factory as UIElementFromSystemLibrary)?.Type;
            if (targetType == null)
                throw new NotSupportedException("Changing the panel from a user library type is currently not supported.");
            if (!typeof(Panel).IsAssignableFrom(targetType))
                throw new ArgumentException(@"The target type is not a panel", nameof(targetType));

            // If the target panel type is the same as the current panel type, do nothing
            if (targetType == ElementType)
                return;

            using (var transaction = Editor.UndoRedoService.CreateTransaction())
            {
                Panel targetPanel = null;
                // Try to maintain the layout order depending on the combinaison of currentType/targetType.
                //
                // Notes:
                // - from any panel to a Canvas (tricky case)
                //    - for now don't do anything smart
                //        + later we could try to calculate Canvas absolute or relative position so that elements appear at the same position
                var stackPanel = AssetSidePanel as StackPanel;
                if (stackPanel != null)

View on GitHub (pinned to 96fad776d2)