stride3d/stride · error · ArgumentException
The value of this converter must be convertible to a double.
Error message
The value of this converter must be convertible to a double.
What it means
NumericToSize multiplies a WPF Size structure (given as the converter parameter) by a numeric scalar (the bound value). The scalar is obtained via ConverterHelper.ConvertToDouble; when that conversion fails the library wraps the failure in this ArgumentException with the original exception as InnerException. It exists to fail fast when the bound value is not numeric rather than produce a degenerate Size.
Solutions
- Bind a numeric property (int/double) as the converter value
- Inspect InnerException to find the offending value
- Parse strings to numbers in the view model before binding
- Use CultureInfo-invariant parsing if strings come from user input
Example fix
// before <Binding Path="WidthText"/> <!-- "12,5" string --> // after <Binding Path="Width"/> <!-- double 12.5 -->
Defensive patterns
Strategy: validation
Validate before calling
bool CanScaleToSize(object value) =>
value is double || value is int || value is float || value is long || value is decimal ||
(value is string s && double.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out _)); Type guard
bool IsDoubleConvertible(object v) => v is double || v is int || v is float || v is long || v is decimal;
Try / catch
try
{
return converter.Convert(value, typeof(Size), sizeParameter, culture);
}
catch (ArgumentException ex)
{
Log(ex.InnerException);
return (Size)sizeParameter; // unscaled fallback
} Prevention
- Bind numeric properties, not strings, as the scalar
- Use invariant parsing for user-entered numbers before they reach the converter
- Inspect InnerException when diagnosing culture/format issues
- Keep conversion of raw inputs in the view model layer
When it happens
Trigger: Convert(value, targetType, parameter, culture) is called with a value that ConverterHelper.ConvertToDouble cannot interpret: a non-numeric string like "auto", a Brush/Control instance, null, or a badly formatted localized number.
Common situations: Binding a string dimension (e.g. from a TextBox) instead of a numeric property; binding an object/enum to a Size-scaled element; culture-specific decimal separators breaking string-to-double conversion.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- The parameter of this converter must be an instance of the…
- The value of the ConvertBack method of this converter must…
- The parameter of the ConvertBack method of this converter…
- The value of this converter must be convertible to a double.
- The value of the ConvertBack method of this converter must…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/169c6550271814d9.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/NumericToSize.cs:31
/// A <see cref="Size"/> must be passed as a parameter of this converter. You can use the <see cref="MarkupExtensions.SizeExtension"/>
/// markup extension to easily pass one, with the following syntax: {sd:Size (arguments)}. The resulting size will
/// be the parameter size multiplied bu the scalar double value.
/// </summary>
[ValueConversion(typeof(double), typeof(Size))]
public class NumericToSize : ValueConverterBase<NumericToSize>
{
/// <inheritdoc/>
[NotNull]
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double scalar;
try
{
scalar = ConverterHelper.ConvertToDouble(value, culture);
}
catch (Exception exception)
{
throw new ArgumentException("The value of this converter must be convertible to a double.", exception);
}
if (!(parameter is Size))
{
throw new ArgumentException("The parameter of this converter must be an instance of the Size structure. Use {sd:Size (arguments)} to construct one.");
}
var size = (Size)parameter;
var result = new Size(size.Width * scalar, size.Height * scalar);
return result;
}
/// <inheritdoc/>
public override object ConvertBack(object value, [NotNull] Type targetType, object parameter, CultureInfo culture)
{
if (!(value is Size))
{
throw new ArgumentException("The value of the ConvertBack method of this converter must be a an instance of the Size structure.");View on GitHub (pinned to 96fad776d2)