{"record":{"id":"38422323fec4acf7","repo":"stride3d/stride","slug":"the-parameter-of-the-convertback-method-of-this-converter-384223","errorCode":null,"errorMessage":"The parameter of the ConvertBack method of this converter must be a an instance of the Thickness structure.","messagePattern":"The parameter of the ConvertBack method of this converter must be a an instance of the Thickness structure\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/SumThickness.cs","lineNumber":28,"sourceCode":"{\n    /// <summary>\n    /// This converter will sum a given <see cref=\"Thickness\"/> with a <see cref=\"Thickness\"/> passed as parameter. You can use\n    /// the <see cref=\"MarkupExtensions.ThicknessExtension\"/> markup extension to easily pass one, with the following syntax: {sd:Thickness (arguments)}. \n    /// </summary>\n    [ValueConversion(typeof(Thickness), typeof(Thickness))]\n    public class SumThickness : ValueConverterBase<SumThickness>\n    {\n        /// <inheritdoc/>\n        [NotNull]\n        public override object Convert(object value, 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            }\n\n            var sizeValue = (Thickness)value;\n            var sizeParameter = (Thickness)parameter;\n            var result = new Thickness(sizeValue.Left + sizeParameter.Left, sizeValue.Top + sizeParameter.Top, sizeValue.Right + sizeParameter.Right, sizeValue.Bottom + sizeParameter.Bottom);\n            return result;\n        }\n\n        /// <inheritdoc/>\n        [NotNull]\n        public override object ConvertBack(object value, 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            {","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/SumThickness.cs#L10-L46","documentation":"SumThickness.Convert requires the ConverterParameter to be a Thickness so it can add Left/Top/Right/Bottom component-wise. It throws this ArgumentException from Convert (SumThickness.cs:28) when `parameter` is not a Thickness.","triggerScenarios":"Setting ConverterParameter to a string like \"1,2,3,4\" or a double in XAML while using SumThickness in a forward (Convert) binding; calling Convert directly with a non-Thickness parameter.","commonSituations":"XAML ConverterParameter only produces strings, so this throws for nearly every XAML-based usage unless a Size/Thickness resource is supplied; copying patterns from converters that parse string parameters.","solutions":["Supply the parameter as a Thickness resource: `<Thickness x:Key=\"Delta\">1,2,3,4</Thickness>` then `ConverterParameter=\"{StaticResource Delta}\"`.","Set the converter parameter in code-behind/ViewModel as `new Thickness(...)`.","Use a Binding (with a Thickness-typed source) instead of ConverterParameter.","Guard with `if (parameter is Thickness)` before calling Convert."],"exampleFix":"// before\n<Border local:SumThickness.ConverterParameter=\"1,2,3,4\" /> <!-- string, throws -->\n// after\n<sys:Thickness x:Key=\"Pad\">1,2,3,4</sys:Thickness>\n<Border local:SumThickness.ConverterParameter=\"{StaticResource Pad}\" />","handlingStrategy":"type-guard","validationCode":"bool ok = parameter is System.Windows.Thickness;","typeGuard":"static bool HasValidParameter(object p) => p is System.Windows.Thickness;","tryCatchPattern":"try { return converter.Convert(value, typeof(Thickness), param, culture); }\ncatch (ArgumentException) { return Binding.DoNothing; }","preventionTips":["Use <Thickness> resources for ConverterParameter instead of strings.","Remember XAML ConverterParameter attributes can only yield strings — never a Thickness.","Prefer MultiBinding or a dedicated converter if you need string-parsed offsets."],"tags":["wpf","valueconverter","converterparameter","type-mismatch"],"backgroundTag":"type-mismatch","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"}