{"record":{"id":"58988538c8043e18","repo":"stride3d/stride","slug":"the-parameter-of-this-converter-must-be-an-instance-of-the-589885","errorCode":null,"errorMessage":"The parameter of this converter must be an instance of the Thickness structure. Use {sd:Thickness (arguments)} to construct one.","messagePattern":"The parameter of this converter must be an instance of the Thickness structure\\. Use (.+?) to construct one\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/NumericToThickness.cs","lineNumber":36,"sourceCode":"    public class NumericToThickness : ValueConverterBase<NumericToThickness>\n    {\n        /// <inheritdoc/>\n        [NotNull]\n        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            double scalar;\n            try\n            {\n                scalar = ConverterHelper.ConvertToDouble(value, culture);\n            }\n            catch (Exception exception)\n            {\n                throw new ArgumentException(\"The value of this converter must be convertible to a double.\", exception);\n            }\n\n            if (!(parameter is Thickness))\n            {\n                throw new ArgumentException(\"The parameter of this converter must be an instance of the Thickness structure. Use {sd:Thickness (arguments)} to construct one.\");\n            }\n\n            var thickness = (Thickness)parameter;\n            var result = new Thickness(thickness.Left * scalar, thickness.Top * scalar, thickness.Right * scalar, thickness.Bottom * scalar);\n            return result;\n        }\n\n        /// <inheritdoc/>\n        public override object ConvertBack(object value, [NotNull] Type targetType, object parameter, CultureInfo culture)\n        {\n            if (!(value is Thickness))\n            {\n                throw new ArgumentException(\"The value of the ConvertBack method of this converter must be a an instance of the Thickness structure.\");\n            }\n            if (!(parameter is Thickness))\n            {\n                throw new ArgumentException(\"The parameter of the ConvertBack method of this converter must be a an instance of the Thickness structure.\");\n            }","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/NumericToThickness.cs#L18-L54","documentation":"NumericToThickness requires the ConverterParameter to be a WPF System.Windows.Thickness, whose four sides are each scaled by the numeric bound value. If the parameter is null or not a Thickness (e.g. a plain string), this ArgumentException is thrown. The message recommends the {sd:Thickness (arguments)} markup extension for constructing the parameter in XAML.","triggerScenarios":"ConverterParameter=\"10\" or \"10,10,10,10\" (strings) instead of a Thickness instance; parameter omitted so it is null; passing a Size parameter to NumericToThickness by copy-paste mistake.","commonSituations":"Migrating from NumericToSize and reusing a string parameter; XAML tooling that only emits primitive parameters; misunderstanding that the parameter must be a struct instance, not text.","solutions":["Set ConverterParameter=\"{sd:Thickness left, top, right, bottom}\" in XAML","Or supply a Thickness resource/static as the parameter","Confirm the converter is NumericToThickness and the parameter type matches (Thickness, not Size or string)","Move parameter construction into code-behind/view model if markup extensions are unavailable"],"exampleFix":"// before\nConverter=\"{sd:NumericToThickness}\" ConverterParameter=\"5,5,5,5\"\n// after\nConverter=\"{sd:NumericToThickness}\" ConverterParameter=\"{sd:Thickness 5,5,5,5}\"","handlingStrategy":"type-guard","validationCode":"bool IsValidThicknessParameter(object parameter) => parameter is System.Windows.Thickness;","typeGuard":"bool IsThickness(object p) => p is System.Windows.Thickness;","tryCatchPattern":"try\n{\n    return converter.Convert(value, typeof(Thickness), parameter, culture);\n}\ncatch (ArgumentException)\n{\n    return new Thickness(0);\n}","preventionTips":["Use ConverterParameter=\"{sd:Thickness left, top, right, bottom}\" in XAML","Do not pass raw strings or Size instances as the parameter","Double-check the converter/parameter pairing when copy-pasting from NumericToSize usages","Prefer Thickness resources over literal string parameters"],"tags":["wpf","valueconverter","thickness","converterparameter"],"backgroundTag":"invalid-argument-value","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"}