{"record":{"id":"b11b0c32e6adbc85","repo":"stride3d/stride","slug":"the-parameter-of-this-converter-must-be-an-instance-of-the","errorCode":null,"errorMessage":"The parameter of this converter must be an instance of the Size structure. Use {sd:Size (arguments)} to construct one.","messagePattern":"The parameter of this converter must be an instance of the Size structure\\. Use (.+?) to construct one\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/NumericToSize.cs","lineNumber":36,"sourceCode":"    public class NumericToSize : ValueConverterBase<NumericToSize>\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 Size))\n            {\n                throw new ArgumentException(\"The parameter of this converter must be an instance of the Size structure. Use {sd:Size (arguments)} to construct one.\");\n            }\n\n            var size = (Size)parameter;\n            var result = new Size(size.Width * scalar, size.Height * 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 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            }","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/NumericToSize.cs#L18-L54","documentation":"NumericToSize requires its ConverterParameter to be a WPF System.Windows.Size instance, which the converter scales by the numeric bound value. If the parameter is missing, is a string, or is any other type, this ArgumentException is thrown. The message points to the {sd:Size (arguments)} markup extension as the intended way to construct the parameter in XAML.","triggerScenarios":"Using ConverterParameter=\"100,50\" (a string) instead of a Size instance; omitting ConverterParameter entirely (parameter is null); passing a numeric or Thickness parameter by mistake to NumericToSize.","commonSituations":"Copy-pasting a converter usage from NumericToThickness and leaving a string parameter; authors unfamiliar with markup extensions passing raw XAML strings as parameters; tooling that only supports primitive ConverterParameter values.","solutions":["Declare the parameter with the sd:Size markup extension, e.g. ConverterParameter=\"{sd:Size 100, 50}\"","Or bind a Size resource/static value as ConverterParameter","Verify you did not confuse NumericToSize with a converter that takes string parameters","If the string form is unavoidable, wrap in a markup extension or convert to Size before binding"],"exampleFix":"// before\nConverter=\"{sd:NumericToSize}\" ConverterParameter=\"100,50\"\n// after\nConverter=\"{sd:NumericToSize}\" ConverterParameter=\"{sd:Size 100, 50}\"","handlingStrategy":"type-guard","validationCode":"bool IsValidSizeParameter(object parameter) => parameter is System.Windows.Size;","typeGuard":"bool IsSize(object p) => p is System.Windows.Size size && !double.IsNaN(size.Width) && !double.IsNaN(size.Height);","tryCatchPattern":"try\n{\n    return converter.Convert(value, typeof(Size), parameter, culture);\n}\ncatch (ArgumentException)\n{\n    return new Size(0, 0);\n}","preventionTips":["Always construct the parameter with ConverterParameter=\"{sd:Size w, h}\"","Never pass raw strings like \"100,50\" as ConverterParameter for this converter","Check parameter type at binding authoring time with a debug converter or trace output","Prefer a Size resource (StaticResource) over string parameters"],"tags":["wpf","valueconverter","size","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"}