{"record":{"id":"1463d3a784cc4076","repo":"AvaloniaUI/Avalonia","slug":"gradient-of-type-gradientbrush-gettype-is-not","errorCode":null,"errorMessage":"Gradient of type {gradientBrush?.GetType()} is not supported","messagePattern":"Gradient of type (.+?) is not supported","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Avalonia.Base/Animation/Animators/GradientBrushAnimator.cs","lineNumber":150,"sourceCode":"                        oldRadial.SpreadMethod, oldRadial.Center, oldRadial.GradientOrigin,\n                        oldRadial.RadiusX, oldRadial.RadiusY);\n\n                case IConicGradientBrush oldConic:\n                    return new ImmutableConicGradientBrush(\n                        CreateStopsFromSolidColorBrush(solidColorBrush, oldConic.GradientStops), solidColorBrush.Opacity,\n                        oldConic.Transform is { } ? new ImmutableTransform(oldConic.Transform.Value) : null,\n                        oldConic.TransformOrigin,\n                        oldConic.SpreadMethod, oldConic.Center, oldConic.Angle);\n\n                case ILinearGradientBrush oldLinear:\n                    return new ImmutableLinearGradientBrush(\n                        CreateStopsFromSolidColorBrush(solidColorBrush, oldLinear.GradientStops), solidColorBrush.Opacity,\n                        oldLinear.Transform is { } ? new ImmutableTransform(oldLinear.Transform.Value) : null,\n                        oldLinear.TransformOrigin,\n                        oldLinear.SpreadMethod, oldLinear.StartPoint, oldLinear.EndPoint);\n\n                default:\n                    throw new NotSupportedException($\"Gradient of type {gradientBrush?.GetType()} is not supported\");\n            }\n\n            static IReadOnlyList<ImmutableGradientStop> CreateStopsFromSolidColorBrush(ISolidColorBrush solidColorBrush, IReadOnlyList<IGradientStop> baseStops)\n            {\n                var stops = new ImmutableGradientStop[baseStops.Count];\n                for (int index = 0; index < baseStops.Count; index++)\n                {\n                    stops[index] = new ImmutableGradientStop(baseStops[index].Offset, solidColorBrush.Color);\n                }\n                return stops;\n            }\n        }\n    }\n}\n","sourceCodeStart":132,"sourceCodeEnd":165,"githubUrl":"https://github.com/AvaloniaUI/Avalonia/blob/11c542726898ae954a1ef668c65ec79ec92ab17d/src/Avalonia.Base/Animation/Animators/GradientBrushAnimator.cs#L132-L165","documentation":"Thrown by GradientBrushAnimator interpolation when the old brush is a gradient type that the animator does not handle. The default case covers any IGradientBrush that is neither a conic nor a linear gradient brush (e.g. a radial gradient), which this animator cannot interpolate.","triggerScenarios":"Interpolating toward/away from an IGradientBrush whose concrete type is not IConicGradientBrush or ILinearGradientBrush (notably IRadialGradientBrush).","commonSituations":"Switching a control's background from a RadialGradientBrush to a solid/linear brush while a gradient animation is active; animating a property that can hold arbitrary IBrush values.","solutions":["Animate only Linear or Conic gradient brushes with GradientBrushAnimator.","Avoid animating across incompatible brush kinds; settle the target to a supported gradient type first.","Use SolidColorBrushAnimator when animating solid color brushes."],"exampleFix":"// before\ncontrol.Background = new RadialGradientBrush(...); // then gradient-animated\n\n// after\ncontrol.Background = new LinearGradientBrush(...); // supported gradient type","handlingStrategy":"validation","validationCode":"if (control.Background is IRadialGradientBrush)\n    throw new NotSupportedException(\"RadialGradientBrush is not supported by GradientBrushAnimator.\");","typeGuard":"static bool IsSupportedGradient(IBrush? b) => b is ILinearGradientBrush or IConicGradientBrush;","tryCatchPattern":null,"preventionTips":["Restrict gradient animations to Linear or Conic gradient brushes.","Settle the control's brush to a supported gradient type before animating.","Use SolidColorBrushAnimator for solid color transitions."],"tags":["animation","brush","unsupported-type","avalonia"],"backgroundTag":null,"analyzedSha":"11c542726898ae954a1ef668c65ec79ec92ab17d","analyzedAt":"2026-08-13T11:57:40.261Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}