{"record":{"id":"149feda63e4a394c","repo":"stride3d/stride","slug":"this-multi-converter-must-be-invoked-with-at-least-two","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/AllEqualMultiConverter.cs","lineNumber":19,"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.\n\nusing System;\nusing System.Globalization;\nusing System.Linq;\nusing System.Windows;\nusing Stride.Core.Annotations;\nusing Stride.Core.Presentation.Internal;\n\nnamespace Stride.Core.Presentation.ValueConverters\n{\n    public class AllEqualMultiConverter : OneWayMultiValueConverter<AllEqualMultiConverter>\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 fallbackValue = parameter is bool && (bool)parameter;\n            var first = values[0];\n            var result = values.All(x => x == DependencyProperty.UnsetValue ? fallbackValue : Equals(x, first));\n            return result.Box();\n        }\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":28,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/AllEqualMultiConverter.cs#L1-L28","documentation":"AllEqualMultiConverter.Convert throws this InvalidOperationException when the MultiBinding supplies fewer than two values, since comparing 'all equal' is meaningless with zero or one element. The converter's contract requires at least two bound values.","triggerScenarios":"An IMultiValueConverter binding with a single child binding; all but one child binding failing to produce values; incorrectly wiring the converter to a plain Binding instead of a MultiBinding.","commonSituations":"XAML MultiBinding missing a nested Binding/Path element; a binding silently dropping values so the array shrinks; copy-pasting the converter into a normal Binding.","solutions":["Ensure the MultiBinding contains at least two child Bindings","Verify the converter is attached via <MultiBinding.Converter>, not a single Binding","Check child bindings for errors so values are not pruned to fewer than two"],"exampleFix":"// before\n<Binding Path=\"A\" Converter={StaticResource AllEqualMultiConverter}/>\n// after\n<MultiBinding Converter=\"{StaticResource AllEqualMultiConverter}\">\n  <Binding Path=\"A\"/>\n  <Binding Path=\"B\"/>\n</MultiBinding>","handlingStrategy":"validation","validationCode":"if (values == null || values.Length < 2)\n    throw new InvalidOperationException(\"MultiBinding must supply at least two values\");","typeGuard":"bool HasTwoValues(object[] v) => v != null && v.Length >= 2;","tryCatchPattern":"try { result = AllEqualMultiConverter.Instance.Convert(values, targetType, param, culture); }\ncatch (InvalidOperationException ex) { Log.Warn(\"Multibinding under-populated\", ex); }","preventionTips":["Always use MultiBinding with >= 2 child Bindings for multi converters","Never attach multi converters to a plain Binding","Review XAML for dropped/removed nested Bindings","Convert to the WPF fallback values instead by passing a bool parameter"],"tags":["wpf","value-converter","multibinding","xaml"],"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-15T23:17:13.987Z"}