{"record":{"id":"6f49f61b444a6152","repo":"HandyOrg/HandyControl","slug":"notsupportedexception","errorCode":null,"errorMessage":"NotSupportedException","messagePattern":"NotSupportedException","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Shared/HandyControl_Shared/Tools/Converter/BooleanArr2VisibilityConverter.cs","lineNumber":36,"sourceCode":"\n        var arr = new List<bool>();\n        foreach (var item in values)\n        {\n            if (item is bool boolValue)\n            {\n                arr.Add(boolValue);\n            }\n            else\n            {\n                return Visibility.Collapsed;\n            }\n        }\n        return arr.All(item => item) ? Visibility.Visible : Visibility.Collapsed;\n    }\n\n    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)\n    {\n        throw new NotSupportedException();\n    }\n}\n","sourceCodeStart":18,"sourceCodeEnd":39,"githubUrl":"https://github.com/HandyOrg/HandyControl/blob/2c0875ebd67326e0c67282967e3e809c69282fee/src/Shared/HandyControl_Shared/Tools/Converter/BooleanArr2VisibilityConverter.cs#L18-L39","documentation":"BooleanArr2VisibilityConverter is a one-way converter: ConvertBack is intentionally unimplemented and always throws NotSupportedException. It converts a bool[] into Visibility for display only; converting a Visibility back into a bool array has no defined mapping in this library.","triggerScenarios":"Using BooleanArr2VisibilityConverter in a TwoWay or OneWayToSource binding, or calling ConvertBack directly; a binding that pushes target (Visibility) changes back to the source.","commonSituations":"Forgetting to set Binding Mode=OneWay (default for most controls is TwoWay on editable controls like CheckBox/ComboBox); reusing the converter in an editable control template.","solutions":["Set the binding to Mode=OneWay when using this converter so ConvertBack is never invoked.","Swap to a different converter if you genuinely need two-way bool[]/Visibility conversion, writing your own ConvertBack.","Never call ConvertBack manually on this converter."],"exampleFix":"// before\n{Binding Flags, Converter={StaticResource BooleanArr2VisibilityConverter}} <!-- TwoWay on editable control -->\n// after\n{Binding Flags, Mode=OneWay, Converter={StaticResource BooleanArr2VisibilityConverter}}","handlingStrategy":"type-guard","validationCode":"bool usesConverterBack = binding.Mode == BindingMode.TwoWay || binding.Mode == BindingMode.OneWayToSource;\nif (usesConverterBack && converter is BooleanArr2VisibilityConverter) throw new InvalidOperationException(\"Use Mode=OneWay with BooleanArr2VisibilityConverter\");","typeGuard":"static bool IsOneWay(BindingBase b) => b is Binding bd && bd.Mode == BindingMode.OneWay;","tryCatchPattern":"try { var result = converter.ConvertBack(value, targetTypes, parameter, culture); } catch (NotSupportedException) { return Array.Empty<object>(); // one-way converter: no back conversion\n}","preventionTips":["Set Mode=OneWay on every binding that uses BooleanArr2VisibilityConverter.","Avoid using this converter on editable controls (TextBox, CheckBox) whose defaults are TwoWay.","Write a custom two-way converter if reverse conversion is actually required."],"tags":["converter","wpf","binding","not-supported"],"backgroundTag":"unsupported-operation","analyzedSha":"2c0875ebd67326e0c67282967e3e809c69282fee","analyzedAt":"2026-09-14T14:45:29.754Z","contentChangedAt":"2026-09-14T14:45:29.754Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}