{"record":{"id":"09e792a936697e60","repo":"stride3d/stride","slug":"the-value-of-this-converter-must-be-convertible-to-a-double","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/Multiply.cs","lineNumber":27,"sourceCode":"namespace Stride.Core.Presentation.ValueConverters\n{\n    /// <summary>\n    /// This converter will multiply a given numeric value by the numeric value given as parameter.\n    /// </summary>\n    [ValueConversion(typeof(double), typeof(double))]\n    public class Multiply : ValueConverterBase<Multiply>\n    {\n        /// <inheritdoc/>\n        public override object Convert(object value, [NotNull] 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            double param;\n            try\n            {\n                param = ConverterHelper.ConvertToDouble(parameter, culture);\n            }\n            catch (Exception exception)\n            {\n                throw new ArgumentException(\"The parameter of this converter must be convertible to a double.\", exception);\n            }\n\n            return System.Convert.ChangeType(scalar * param, targetType);\n        }\n\n        /// <inheritdoc/>\n        public override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n        {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/Multiply.cs#L9-L45","documentation":"Multiply.Convert multiplies a value by a parameter, both of which must be convertible to double via ConverterHelper.ConvertToDouble. If the value cannot be converted (wrong type, unparsable string), the original exception is wrapped in an ArgumentException. This fails fast rather than producing silently wrong numeric results.","triggerScenarios":"Binding a non-numeric property (e.g. a string like \"abc\" or an object) to a Multiply converter; calling Convert with a value ConverterHelper.ConvertToDouble cannot handle.","commonSituations":"ViewModel property changed from double to string; binding to a Boolean property; localization issues where a string with wrong decimal separator is passed.","solutions":["Ensure the bound value is numeric or a culture-correct numeric string.","Bind to a double-typed property (e.g. expose double instead of string in the ViewModel).","Use StringFormat or a preceding converter to normalize the value before Multiply."],"exampleFix":"// before\npublic string Scale { get; set; } = \"1.5\"; // may fail on some cultures\n// after\npublic double Scale { get; set; } = 1.5;","handlingStrategy":"type-guard","validationCode":"bool isDoubleConvertible(object? v) => v is double || v is int || v is float || v is decimal || (v is string s && double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out _));","typeGuard":"static bool TryGetDouble(object? v, out double d) => double.TryParse(Convert.ToString(v, CultureInfo.InvariantCulture), NumberStyles.Any, CultureInfo.InvariantCulture, out d);","tryCatchPattern":"try { result = multiply.Convert(value, targetType, parameter, culture); } catch (ArgumentException ex) { /* show validation error; use fallback */ }","preventionTips":["Expose numeric (double) properties for values fed to Multiply","Normalize strings to invariant-format doubles before conversion","Log the inner exception to see the original conversion failure"],"tags":["wpf","value-converter","type-conversion","double"],"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-23T08:17:48.524Z"}