{"record":{"id":"52ace47977677c3c","repo":"stride3d/stride","slug":"the-value-of-the-convertback-method-of-this-converter-must-52ace4","errorCode":null,"errorMessage":"The value of the ConvertBack method of this converter must be a an instance of the Thickness structure.","messagePattern":"The value 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":24,"sourceCode":"using System.Windows.Data;\nusing Stride.Core.Annotations;\n\nnamespace Stride.Core.Presentation.ValueConverters\n{\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            {","sourceCodeStart":6,"sourceCodeEnd":42,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/SumThickness.cs#L6-L42","documentation":"SumThickness.Convert adds two WPF Thickness structures component-wise (Left/Top/Right/Bottom). It throws this ArgumentException from Convert (SumThickness.cs:24) when `value` is not a Thickness, because the addition and cast that follow require it. Note the message says \"ConvertBack\" — a copy-paste bug in the message text; the check lives in Convert.","triggerScenarios":"Binding a non-Thickness value (string, double, Rect, null) into a one-way binding using SumThickness, or calling Convert directly with a non-Thickness object.","commonSituations":"Binding to a Padding/Margin-like property whose source type is a custom thickness or string; null arriving via a failed binding; tests exercising Convert with placeholder objects; confusion with converters that parse \"l,t,r,b\" strings.","solutions":["Make the bound source property a System.Windows.Thickness.","Convert the source value to Thickness (e.g. new Thickness(l,t,r,b)) before it reaches the converter.","Type-guard at the call site: `if (value is Thickness)` before calling Convert.","Wrap the converter to return Binding.DoNothing or a default Thickness for invalid input."],"exampleFix":"// before\nvar t = converter.Convert(new Rect(0,0,5,5), typeof(Thickness), new Thickness(1), culture); // throws\n// after\nvar t = converter.Convert(new Thickness(0,0,5,5), typeof(Thickness), new Thickness(1), culture);","handlingStrategy":"type-guard","validationCode":"bool ok = value is System.Windows.Thickness && parameter is System.Windows.Thickness;","typeGuard":"static bool IsConvertibleValue(object v) => v is System.Windows.Thickness;","tryCatchPattern":"try { return converter.Convert(value, typeof(Thickness), param, culture); }\ncatch (ArgumentException) { return new Thickness(0); }","preventionTips":["Ensure source properties for Padding/Margin math are typed as Thickness.","Handle null/UnsetValue upstream with FallbackValue so converters never receive null.","Note this converter's Convert messages say 'ConvertBack' — a known copy-paste quirk; don't let it mislead debugging."],"tags":["wpf","valueconverter","thickness","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"}