{"record":{"id":"00c846ccc65a79e5","repo":"stride3d/stride","slug":"this-multi-converter-must-be-invoked-with-at-least-two-00c846","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/AndMultiConverter.cs","lineNumber":18,"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 System.Windows;\nusing Stride.Core.Annotations;\nusing Stride.Core.Presentation.Internal;\n\nnamespace Stride.Core.Presentation.ValueConverters\n{\n    public class AndMultiConverter : OneWayMultiValueConverter<AndMultiConverter>\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 result = values.All(x => x == DependencyProperty.UnsetValue ? fallbackValue : (bool)x);\n            return result.Box();\n        }\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/AndMultiConverter.cs#L1-L26","documentation":"AndMultiConverter.Convert throws this InvalidOperationException when invoked with fewer than two values, because a logical AND over zero or one inputs has no defined meaning for this converter. It enforces the minimum input count of the MultiBinding.","triggerScenarios":"MultiBinding with only one child binding; child bindings failing so the values array is shorter than two; attaching the converter to a plain single Binding.","commonSituations":"XAML mistakes where a nested <Binding> is removed or malformed; dynamic bindings that fail at runtime; reuse of the converter in templates with one condition only.","solutions":["Provide at least two child Bindings in the MultiBinding","Attach via <MultiBinding.Converter> only","Use a regular one-way converter instead when a single condition is all you need"],"exampleFix":"// before\n<MultiBinding Converter=\"{StaticResource AndMultiConverter}\">\n  <Binding Path=\"IsEnabled\"/>\n</MultiBinding>\n// after\n<MultiBinding Converter=\"{StaticResource AndMultiConverter}\">\n  <Binding Path=\"IsEnabled\"/>\n  <Binding Path=\"HasPermission\"/>\n</MultiBinding>","handlingStrategy":"validation","validationCode":"if (values == null || values.Length < 2)\n    throw new InvalidOperationException(\"AndMultiConverter needs at least two values\");","typeGuard":"bool HasTwoValues(object[] v) => v != null && v.Length >= 2;","tryCatchPattern":"try { result = AndMultiConverter.Instance.Convert(values, targetType, param, culture); }\ncatch (InvalidOperationException ex) { Log.Warn(\"Insufficient binding values\", ex); }","preventionTips":["Declare at least two child Bindings inside the MultiBinding","Check for runtime binding failures that shrink the values array","Use a single-value converter for one-condition cases","Keep converter usage consistent in templates"],"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"}