{"record":{"id":"e268eb3264ba11cb","repo":"dotnet/wpf","slug":"new-notsupportedexception","errorCode":null,"errorMessage":"new NotSupportedException()","messagePattern":"new NotSupportedException\\(\\)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonContextMenu.cs","lineNumber":445,"sourceCode":"                        {\n                            return RibbonCommands.ShowQuickAccessToolBarAboveRibbonCommand;\n                        }\n                    }\n                }\n\n                if (_mode == ConverterMode.Header)\n                {\n                    return ShowQATBelowText;\n                }\n                else\n                {\n                    return RibbonCommands.ShowQuickAccessToolBarBelowRibbonCommand;\n                }\n            }\n\n            public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n            {\n                throw new NotSupportedException();\n            }\n        }\n\n        private static RibbonMenuItem GenerateMinimizeTheRibbonItem(RibbonContextMenu contextMenu)\n        {\n            RibbonMenuItem minimizeTheRibbonItem = new RibbonMenuItem\n            {\n                CanAddToQuickAccessToolBarDirectly = false,\n                Header = MinimizeTheRibbonText\n            };\n\n            PropertyPath path = new PropertyPath(\"(0).(1).(2)\");\n            path.PathParameters.Add(ContextMenuService.PlacementTargetProperty);\n            path.PathParameters.Add(RibbonControlService.RibbonProperty);\n            path.PathParameters.Add(Ribbon.IsMinimizedProperty);\n\n            Binding isCheckedBinding = new Binding () { Source = contextMenu, Path = path };\n            minimizeTheRibbonItem.SetBinding(RibbonMenuItem.IsCheckedProperty, isCheckedBinding);","sourceCodeStart":427,"sourceCodeEnd":463,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/System.Windows.Controls.Ribbon/Microsoft/Windows/Controls/Ribbon/RibbonContextMenu.cs#L427-L463","documentation":"The internal value converter for the 'Show Quick Access Toolbar below the Ribbon' checkable item implements only one-way conversion (bool/state to a RibbonCommand); its ConvertBack is intentionally unsupported. Calling it throws NotSupportedException because the binding for this menu item never needs two-way conversion.","triggerScenarios":"Invoking ConvertBack on the ShowQuickAccessToolBar converter, e.g. by creating a TwoWay or TwoWay-by-default binding whose converter is this internal converter, or calling it directly via reflection/custom binding code.","commonSituations":"Copy-pasting the Ribbon's internal converters into custom code, or building a custom binding with Mode=TwoWay that reuses the converter from RibbonContextMenu's QuickAccessToolBar menu items.","solutions":["Do not use this converter in TwoWay bindings; keep it one-way (Mode=OneWay) or omit the converter in your own bindings.","Implement your own converter with a working ConvertBack if you need round-tripping of the Quick Access Toolbar position.","If you control the code, wrap ConvertBack in try/catch NotSupportedException only when a one-way binding occasionally evaluates back."],"exampleFix":"// before\nBinding b = new Binding(\"IsChecked\") { Converter = ribbonContextMenuConverter, Mode = BindingMode.TwoWay };\n\n// after\nBinding b = new Binding(\"IsChecked\") { Converter = ribbonContextMenuConverter, Mode = BindingMode.OneWay };","handlingStrategy":"try-catch","validationCode":"if (binding.Mode == BindingMode.TwoWay) throw new InvalidOperationException(\"ShowQuickAccessToolBar converter is one-way only\");","typeGuard":"bool SupportsConvertBack(IValueConverter c) => c.GetType().Name != \"ShowQuickAccessToolBarConverter\"; // internal converter is one-way only","tryCatchPattern":"try { result = converter.ConvertBack(value, targetType, parameter, culture); }\ncatch (NotSupportedException) { result = value; /* converter is one-way by design */ }","preventionTips":["Bind with Mode=OneWay when using internal Ribbon context-menu converters.","Never reuse internal WPF converters in application-level two-way bindings.","Unit-test converters for the binding modes you actually use."],"tags":["wpf","ribbon","notsupported","converter","one-way-binding"],"backgroundTag":"unsupported-operation","analyzedSha":"81131a70a4c573cd62748a5c36908fc4d662daa9","analyzedAt":"2026-09-14T10:12:48.479Z","contentChangedAt":"2026-09-14T10:12:48.479Z","schemaVersion":2},"datasetVersion":"2026-09-22T01:17:13.364Z"}