stride3d/stride · error · ArgumentException

The values of this converter must be convertible to a…

Error message

The values of this converter must be convertible to a double.

What it means

MultiplyMultiConverter converts each bound value to a double via ConverterHelper.ConvertToDouble and multiplies them. If any input value cannot be converted to a double, the underlying conversion throws and this library wraps it in an ArgumentException with the original exception as InnerException. This guards against silently producing NaN or 0 from non-numeric binding sources.

Solutions

  1. Check the InnerException to identify which value failed to convert
  2. Ensure every binding in the MultiBinding exposes a numeric (double-convertible) value
  3. Use StringFormat or a prior converter stage to normalize string inputs to numbers
  4. Validate the bound view-model properties return numeric types

Example fix

// before
<Binding Path="ScaleText"/> <!-- ScaleText is string "fast" -->
// after
<Binding Path="Scale"/> <!-- Scale is double 1.5 -->
Defensive patterns

Strategy: try-catch

Validate before calling

bool AllConvertibleToDouble(object[] values) =>
    values != null && values.All(v => v is double || v is int || v is long || v is float || v is decimal || (v is string s && double.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out _)));

Type guard

bool IsNumeric(object v) => v is double || v is int || v is long || v is float || v is decimal || v is short || v is byte;

Try / catch

try
{
    return converter.Convert(values, typeof(double), null, culture);
}
catch (ArgumentException ex)
{
    Log(ex.InnerException, "Non-numeric value in MultiplyMultiConverter bindings");
    return 1.0;
}

Prevention

When it happens

Trigger: Any element of the values array passed to Convert is a string that is not parseable as a double, a complex object, null handled non-numerically, or another type ConverterHelper.ConvertToDouble rejects, e.g. MultiBinding feeding a Path bound to a Brush or a malformed string.

Common situations: A binding points at a property whose type changed to string or a non-numeric model type after a refactor; a ComboBox selection object (not a number) is bound into the MultiBinding; a localized number string with wrong culture is supplied directly.

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


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/9d6bf3740161f84f. Report an issue: GitHub.

Appendix: source

Thrown at sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/MultiplyMultiConverter.cs:25

namespace Stride.Core.Presentation.ValueConverters
{
    public class MultiplyMultiConverter : OneWayMultiValueConverter<MultiplyMultiConverter>
    {
        [NotNull]
        public override object Convert([NotNull] object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values.Length < 2)
                throw new InvalidOperationException("This multi converter must be invoked with at least two elements");

            var result = 1.0;
            try
            {
                result = values.Select(x => ConverterHelper.ConvertToDouble(x, culture)).Aggregate(result, (current, next) => current * next);
            }
            catch (Exception exception)
            {
                throw new ArgumentException("The values of this converter must be convertible to a double.", exception);
            }

            return result;
        }
    }
}

View on GitHub (pinned to 96fad776d2)