{"record":{"id":"4e798ffbf54ed57e","repo":"stride3d/stride","slug":"the-value-of-this-converter-must-be-convertible-to-a-double-4e798f","errorCode":null,"errorMessage":"The value of this converter must be convertible to a double.","messagePattern":"The value of this converter must be convertible to a double\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/NumericToThickness.cs","lineNumber":31,"sourceCode":"    /// A <see cref=\"Thickness\"/> must be passed as a parameter of this converter. You can use the <see cref=\"MarkupExtensions.ThicknessExtension\"/>\n    /// markup extension to easily pass one, with the following syntax: {sd:Thickness (arguments)}. The resulting thickness will\n    /// be the parameter thickness multiplied bu the scalar double value.\n    /// </summary>\n    [ValueConversion(typeof(double), typeof(Thickness))]\n    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.\");","sourceCodeStart":13,"sourceCodeEnd":49,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/NumericToThickness.cs#L13-L49","documentation":"NumericToThickness multiplies a WPF Thickness (the converter parameter) by a numeric scalar (the bound value). The scalar is produced by ConverterHelper.ConvertToDouble; a failure there is wrapped in this ArgumentException with the original exception attached as InnerException. It fails fast instead of producing a zero or degenerate Thickness.","triggerScenarios":"Convert receives a value that ConverterHelper.ConvertToDouble cannot convert: null, a non-numeric object, an unparseable string like \"auto\" or \"10px\", or a string with wrong culture decimal separators.","commonSituations":"Binding a string thickness/scale from user input directly; binding an enum or object property; culture mismatches where \"1.5\" vs \"1,5\" fails parsing.","solutions":["Bind a numeric property (double/int) as the value","Check InnerException for the failing value and fix its type/format","Parse or normalize strings in the view model before binding","Use invariant culture when converting user-entered numbers"],"exampleFix":"// before\n<Binding Path=\"ScaleText\"/> <!-- \"1,5\" -->\n// after\n<Binding Path=\"Scale\"/> <!-- double 1.5 -->","handlingStrategy":"validation","validationCode":"bool CanScaleThickness(object value) =>\n    value is double || value is int || value is float || value is long || value is decimal ||\n    (value is string s && double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out _));","typeGuard":"bool IsDoubleConvertible(object v) => v is double || v is int || v is float || v is long || v is decimal;","tryCatchPattern":"try\n{\n    return converter.Convert(value, typeof(Thickness), thicknessParameter, culture);\n}\ncatch (ArgumentException ex)\n{\n    Log(ex.InnerException);\n    return (Thickness)thicknessParameter; // unscaled fallback\n}","preventionTips":["Bind numeric (double/int) properties as the scalar value","Normalize culture-specific number strings before binding","Inspect InnerException to find the offending value","Keep parsing in the view model, not in XAML converters"],"tags":["wpf","valueconverter","thickness","double-conversion"],"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"}