stride3d/stride · error · ArgumentException

This converter supports only between two and eight elements

Error message

This converter supports only between two and eight elements

What it means

MultiBindingToTuple.Convert packs 2-8 bound values into a Tuple<object,...>. The switch only handles tuples of arity 2 through 8; any other count (0, 1, 9+) falls to the default case and throws ArgumentException. The converter simply has no tuple type to build for those arities.

Solutions

  1. Ensure the MultiBinding has between 2 and 8 Binding children.
  2. Remove the extra Binding or split the MultiBinding into two chained converters if more than 8 values are needed.
  3. Compose values into a single object (e.g. a value-tuple property on the ViewModel) instead of exceeding 8 bindings.

Example fix

<!-- before: 9 bindings -->
<MultiBinding Converter="{StaticResource multiBindingToTuple}"><Binding Path="A"/>...<Binding Path="I"/></MultiBinding>
<!-- after: group extra values -->
<MultiBinding Converter="{StaticResource multiBindingToTuple}"><Binding Path="A"/>...<Binding Path="H"/></MultiBinding>
Defensive patterns

Strategy: validation

Validate before calling

bool tupleSupported(object[] values) => values is { Length: >= 2 and <= 8 };

Try / catch

try { result = converter.Convert(values, typeof(object), null, CultureInfo.InvariantCulture); } catch (ArgumentException) { result = Tuple.Create((object)values); }

Prevention

When it happens

Trigger: Using a MultiBinding with fewer than two or more than eight Binding children on this converter, or calling Convert directly with an array of length 0, 1, or 9+.

Common situations: XAML MultiBinding accidentally left with a single binding after removing a value; adding a ninth binding when the limit was 8; tests invoking Convert with empty arrays.

Understand the failure class

Background: "value must be between 0 and 1" / "out of range" / "must not be negative" errors: fixing range-validation failures across open-source libraries — this error's family across 42 libraries.

Related errors


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

Appendix: source

Thrown at sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/MultiBindingToTuple.cs:23

using Stride.Core.Annotations;

namespace Stride.Core.Presentation.ValueConverters
{
    public class MultiBindingToTuple : OneWayMultiValueConverter<MultiBindingToTuple>
    {
        [NotNull]
        public override object Convert([NotNull] object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            switch (values.Length)
            {
                case 2: return new Tuple<object, object>(values[0], values[1]);
                case 3: return new Tuple<object, object, object>(values[0], values[1], values[2]);
                case 4: return new Tuple<object, object, object, object>(values[0], values[1], values[2], values[3]);
                case 5: return new Tuple<object, object, object, object, object>(values[0], values[1], values[2], values[3], values[4]);
                case 6: return new Tuple<object, object, object, object, object, object>(values[0], values[1], values[2], values[3], values[4], values[5]);
                case 7: return new Tuple<object, object, object, object, object, object, object>(values[0], values[1], values[2], values[3], values[4], values[5], values[6]);
                case 8: return new Tuple<object, object, object, object, object, object, object, object>(values[0], values[1], values[2], values[3], values[4], values[5], values[6], values[7]);
                default: throw new ArgumentException("This converter supports only between two and eight elements");
            }
        }
    }
}

View on GitHub (pinned to 96fad776d2)