{"record":{"id":"1f1136151f0fab6f","repo":"stride3d/stride","slug":"this-multi-converter-must-be-invoked-with-at-least-two-1f1136","errorCode":null,"errorMessage":"This multi converter must be invoked with at least two elements","messagePattern":"This multi converter must be invoked with at least two elements","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/MultiplyMultiConverter.cs","lineNumber":16,"sourceCode":"// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)\n// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.\nusing System;\nusing System.Globalization;\nusing System.Linq;\nusing Stride.Core.Annotations;\n\nnamespace Stride.Core.Presentation.ValueConverters\n{\n    public class MultiplyMultiConverter : OneWayMultiValueConverter<MultiplyMultiConverter>\n    {\n        [NotNull]\n        public override object Convert([NotNull] object[] values, Type targetType, object parameter, CultureInfo culture)\n        {\n            if (values.Length < 2)\n                throw new InvalidOperationException(\"This multi converter must be invoked with at least two elements\");\n\n            var result = 1.0;\n            try\n            {\n                result = values.Select(x => ConverterHelper.ConvertToDouble(x, culture)).Aggregate(result, (current, next) => current * next);\n            }\n            catch (Exception exception)\n            {\n                throw new ArgumentException(\"The values of this converter must be convertible to a double.\", exception);\n            }\n\n            return result;\n        }\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/MultiplyMultiConverter.cs#L1-L32","documentation":"MultiplyMultiConverter is a WPF IMultiValueConverter that multiplies all of its input bindings together to produce a single double result. It requires at least two bound values because multiplying fewer than two elements is meaningless for this converter. The library throws this InvalidOperationException when the converter is invoked with a values array of length 0 or 1, which typically means the XAML MultiBinding is missing or has only one Binding child.","triggerScenarios":"Calling Convert(object[] values, ...) with an array of length < 2, e.g. a MultiBinding with no <Binding> children, a MultiBinding with exactly one binding, or programmatic invocation passing new object[] { 1.0 } or an empty array.","commonSituations":"XAML refactoring accidentally removed one of the MultiBinding's Binding elements; a binding failed to resolve so WPF passed a shorter values array; a developer unit-testing or calling the converter directly forgot to supply at least two values.","solutions":["Ensure the MultiBinding in XAML declares at least two <Binding> children inside <MultiBinding.Converter>","Check that all source bindings resolve to non-null values at conversion time","If calling Convert programmatically, pass an array with two or more elements","Use an IMultiValueConverter wrapper or fallback value (FallbackValue/TargetNullValue) for optional bindings"],"exampleFix":"// before\n<MultiBinding Converter=\"{sd:MultiplyMultiConverter}\">\n  <Binding Path=\"Width\"/>\n</MultiBinding>\n// after\n<MultiBinding Converter=\"{sd:MultiplyMultiConverter}\">\n  <Binding Path=\"Width\"/>\n  <Binding Path=\"Scale\"/>\n</MultiBinding>","handlingStrategy":"validation","validationCode":"if (values == null || values.Length < 2)\n    throw new InvalidOperationException(\"MultiplyMultiConverter requires at least two bound values\");","typeGuard":"bool HasEnoughValues(object[] values) => values != null && values.Length >= 2;","tryCatchPattern":"try\n{\n    var result = converter.Convert(values, typeof(double), null, CultureInfo.CurrentCulture);\n}\ncatch (InvalidOperationException ex)\n{\n    // log & fall back to a default product value\n}","preventionTips":["Always declare at least two <Binding> children inside a MultiBinding using this converter","Review XAML after refactors to confirm no Binding children were removed","Add FallbackValue on individual bindings so failed bindings do not shrink the values array","Cover converters with unit tests that pass exactly two-plus values"],"tags":["wpf","xaml","multibinding","argument-count"],"backgroundTag":"missing-required-argument","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"}