{"record":{"id":"7b8275476f0aaa51","repo":"HandyOrg/HandyControl","slug":"notsupportedexception-borderclipconverter","errorCode":null,"errorMessage":"NotSupportedException","messagePattern":"NotSupportedException","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Shared/HandyControl_Shared/Tools/Converter/BorderClipConverter.cs","lineNumber":47,"sourceCode":"                        new ArcSegment(new Point(width - radius.BottomRight, height), new Size(radius.BottomRight, radius.BottomRight), 90, false, SweepDirection.Clockwise, false),\n                        new LineSegment(new Point(radius.BottomLeft, height), false),\n                        new ArcSegment(new Point(0, height - radius.BottomLeft), new Size(radius.BottomLeft, radius.BottomLeft), 90, false, SweepDirection.Clockwise, false),\n                        new LineSegment(new Point(0, radius.TopLeft), false),\n                        new ArcSegment(new Point(radius.TopLeft, 0), new Size(radius.TopLeft, radius.TopLeft), 90, false, SweepDirection.Clockwise, false),\n                    }, false)\n                }\n            };\n            clip.Freeze();\n\n            return clip;\n        }\n\n        return DependencyProperty.UnsetValue;\n    }\n\n    public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)\n    {\n        throw new NotSupportedException();\n    }\n}\n","sourceCodeStart":29,"sourceCodeEnd":50,"githubUrl":"https://github.com/HandyOrg/HandyControl/blob/2c0875ebd67326e0c67282967e3e809c69282fee/src/Shared/HandyControl_Shared/Tools/Converter/BorderClipConverter.cs#L29-L50","documentation":"BorderClipConverter produces a clip geometry for border elements (returning DependencyProperty.UnsetValue for degenerate sizes) and is one-way; ConvertBack unconditionally throws NotSupportedException. Reverse conversion from clip geometry back to the source value is intentionally not provided.","triggerScenarios":"Using BorderClipConverter in a TwoWay/OneWayToSource binding, or calling ConvertBack directly; applying it on an editable control whose properties bind TwoWay by default.","commonSituations":"Styling TextBox/ComboBox templates with this clip converter and missing the OneWay mode; copying the converter usage between read-only and editable elements.","solutions":["Set Binding Mode=OneWay on bindings using BorderClipConverter.","Write a custom converter with a real ConvertBack if you need two-way behavior.","Use the converter only on decorative clip properties, not on data properties."],"exampleFix":"// before\n{Binding ActualWidth, Converter={StaticResource BorderClipConverter}}\n// after\n{Binding ActualWidth, Mode=OneWay, Converter={StaticResource BorderClipConverter}}","handlingStrategy":"type-guard","validationCode":"bool usesConverterBack = binding.Mode == BindingMode.TwoWay || binding.Mode == BindingMode.OneWayToSource;\nif (usesConverterBack && converter is BorderClipConverter) throw new InvalidOperationException(\"Use Mode=OneWay with BorderClipConverter\");","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\n}","preventionTips":["Set Mode=OneWay on every binding that uses BorderClipConverter.","Use the converter only for Clip/geometry decoration, never on data-bound two-way properties.","Audit control templates (TextBox, ComboBox) after restyling to confirm no TwoWay clip bindings remain."],"tags":["converter","wpf","clip","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"}