{"record":{"id":"a8a749309e9c158e","repo":"stride3d/stride","slug":"inconsistent-number-of-parameters-expected-1-2-or-4-values","errorCode":null,"errorMessage":"Inconsistent number of parameters: expected 1, 2 or 4 values, got {values.Length}.","messagePattern":"Inconsistent number of parameters: expected 1, 2 or 4 values, got (.+?)\\.","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/ThicknessMultiConverter.cs","lineNumber":36,"sourceCode":"            {\n                case 1:\n                    var uniform = ConverterHelper.ConvertToDouble(values[0], culture);\n                    return new Thickness(uniform);\n\n                case 2:\n                    var horizontal = ConverterHelper.ConvertToDouble(values[0], culture);\n                    var vertical = ConverterHelper.ConvertToDouble(values[1], culture);\n                    return new Thickness(horizontal, vertical, horizontal, vertical);\n\n                case 4:\n                    var left = ConverterHelper.ConvertToDouble(values[0], culture);\n                    var top = ConverterHelper.ConvertToDouble(values[1], culture);\n                    var right = ConverterHelper.ConvertToDouble(values[2], culture);\n                    var bottom = ConverterHelper.ConvertToDouble(values[3], culture);\n                    return new Thickness(left, top, right, bottom);\n\n                default:\n                    throw new ArgumentException($\"Inconsistent number of parameters: expected 1, 2 or 4 values, got {values.Length}.\", nameof(values));\n            }\n        }\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":41,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/ThicknessMultiConverter.cs#L18-L41","documentation":"ThicknessMultiConverter.Convert builds a Thickness from an array of binding values and accepts exactly 1 (uniform), 2 (horizontal/vertical), or 4 (left/top/right/bottom) values. It throws this ArgumentException from Convert (ThicknessMultiConverter.cs:36) in the switch's default branch when values.Length is anything else (0, 3, 5+).","triggerScenarios":"A MultiBinding with 0, 3, or more than 4 child bindings feeding this converter — e.g. three separate left/top/right bindings, or an empty bindings list.","commonSituations":"Adding/removing a binding in XAML without updating the count expected by the converter; forgetting to bind the fourth side; building the MultiBinding programmatically and miscounting.","solutions":["Adjust the MultiBinding so it contains exactly 1, 2, or 4 child bindings.","If you have 3 values, add the missing one or supply a uniform value so the count is 4 (or 2/1 as appropriate).","If the count is legitimately variable, extend or wrap the converter to handle other arities.","Validate bindings.Length before assigning the converter in code."],"exampleFix":"// before\n<multi:Binding .../> <!-- 3 bindings: left, top, right -->\n// after (add the missing bottom binding)\n<multi:Binding .../> <!-- 4 bindings: left, top, right, bottom -->","handlingStrategy":"validation","validationCode":"bool ok = values is not null && (values.Length == 1 || values.Length == 2 || values.Length == 4);","typeGuard":"static bool HasValidArity(object[] v) => v is { Length: 1 or 2 or 4 };","tryCatchPattern":"try { return converter.Convert(values, typeof(Thickness), param, culture); }\ncatch (ArgumentException) { return new Thickness(0); }","preventionTips":["Count MultiBinding children whenever you add or remove a binding in XAML.","Remember the supported arities: 1 (uniform), 2 (horizontal/vertical), 4 (l/t/r/b).","Build complex MultiBindings in code where counts are checked at compile/author time."],"tags":["wpf","multibinding","valueconverter","arity"],"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-23T08:17:48.524Z"}