{"record":{"id":"1aec0bac8e1d9bba","repo":"stride3d/stride","slug":"the-parameter-of-the-convertback-method-of-this-converter-1aec0b","errorCode":null,"errorMessage":"The parameter of the ConvertBack method of this converter must be a an instance of the Size structure.","messagePattern":"The parameter of the ConvertBack method of this converter must be a an instance of the Size structure\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/SumSize.cs","lineNumber":28,"sourceCode":"{\n    /// <summary>\n    /// This converter will sum a given <see cref=\"Size\"/> with a <see cref=\"Size\"/> passed as parameter. You can use the <see cref=\"MarkupExtensions.SizeExtension\"/>\n    /// markup extension to easily pass one, with the following syntax: {sd:Size (arguments)}. \n    /// </summary>\n    [ValueConversion(typeof(Size), typeof(Size))]\n    public class SumSize : ValueConverterBase<SumSize>\n    {\n        /// <inheritdoc/>\n        [NotNull]\n        public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            if (!(value is Size))\n            {\n                throw new ArgumentException(\"The value of the ConvertBack method of this converter must be a an instance of the Size structure.\");\n            }\n            if (!(parameter is Size))\n            {\n                throw new ArgumentException(\"The parameter of the ConvertBack method of this converter must be a an instance of the Size structure.\");\n            }\n\n            var sizeValue = (Size)value;\n            var sizeParameter = (Size)parameter;\n            var result = new Size(sizeValue.Width + sizeParameter.Width, sizeValue.Height + sizeParameter.Height);\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 Size))\n            {\n                throw new ArgumentException(\"The value of the ConvertBack method of this converter must be a an instance of the Size structure.\");\n            }\n            if (!(parameter is Size))\n            {","sourceCodeStart":10,"sourceCodeEnd":46,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/SumSize.cs#L10-L46","documentation":"SumSize.Convert's second validation throws ArgumentException when the converter parameter is not a System.Windows.Size; both operands must be Size so their Width/Height can be added. Like its sibling check, the message text says 'ConvertBack method' although it is raised inside Convert — a known copy/paste typo in the source.","triggerScenarios":"Invoking SumSize.Convert (or configuring the converter in XAML) with ConverterParameter that is not a Size — e.g. ConverterParameter='10' (parsed as string/double), a Thickness, or a binding-supplied non-Size object.","commonSituations":"Supplying numeric XAML parameters expecting scalar addition; copying parameter style from NumericToThickness converters; passing a Thickness where a Size is expected.","solutions":["Set ConverterParameter to a Size, e.g. in XAML pass a value the parser creates as Size or construct it in code: new Size(w,h).","Create the parameter in code-behind or a resource with x:Type Size semantics.","Use the scalar-appropriate converter if the parameter is a plain number."],"exampleFix":"// before\n<MultiBinding Converter=\"{StaticResource SumSize}\" ConverterParameter=\"10\" />\n// after\nbinding.ConverterParameter = new System.Windows.Size(10, 10);","handlingStrategy":"type-guard","validationCode":"bool ok = parameter is System.Windows.Size;","typeGuard":"static bool IsSizeParameter(object parameter) => parameter is System.Windows.Size;","tryCatchPattern":"try { return sumSize.Convert(value, targetType, parameter, culture); }\ncatch (ArgumentException) { return Binding.DoNothing; }","preventionTips":["Set ConverterParameter to a Size instance, not a raw number","Create parameters in code-behind or via resources when XAML parsing is ambiguous","Use scalar converters for numeric parameters instead","Beware the message text mentions ConvertBack although thrown from Convert"],"tags":["wpf","valueconverter","type-mismatch","size"],"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"}