{"record":{"id":"4943fd91a546aa09","repo":"dotnet/wpf","slug":"notsupportedexception-convertback-not-supported","errorCode":null,"errorMessage":"NotSupportedException (ConvertBack not supported)","messagePattern":"NotSupportedException \\(ConvertBack not supported\\)","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Controls/ViewIsGridViewConverter.cs","lineNumber":23,"sourceCode":"using System.Collections.Generic;\nusing System.Globalization;\nusing System.Text;\nusing System.Windows.Controls;\nusing System.Windows.Data;\n\nnamespace Fluent.Controls\n{\n    internal class ViewIsGridViewConverter : IValueConverter\n    {\n        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            // Returns true if value is a GridView, otherwise false\n            return value is GridView;\n        }\n\n        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            throw new NotSupportedException();\n        }\n    }\n}\n","sourceCodeStart":5,"sourceCodeEnd":27,"githubUrl":"https://github.com/dotnet/wpf/blob/81131a70a4c573cd62748a5c36908fc4d662daa9/src/Microsoft.DotNet.Wpf/src/Themes/PresentationFramework.Fluent/Controls/ViewIsGridViewConverter.cs#L5-L27","documentation":"ViewIsGridViewConverter checks whether a value is a GridView and its ConvertBack throws NotSupportedException to signal that a view can never be converted back to a GridView. Unlike its siblings this is a NotSupportedException, an intentional one-way converter contract.","triggerScenarios":"Binding with ViewIsGridViewConverter in TwoWay or OneWayToSource mode, causing ConvertBack invocation.","commonSituations":"ListView.View bindings accidentally set to TwoWay; refactorings that flip binding modes in styles or templates.","solutions":["Declare the binding as Mode=OneWay.","Never bind a source property back through this converter; use separate converters per direction.","If round-trip semantics are required, write a custom converter implementing ConvertBack meaningfully."],"exampleFix":"// before\n<ListView.View Binding=\"{Binding CurrentView, Converter={StaticResource ViewIsGridViewConverter}, Mode=TwoWay}\" />\n// after\n<ListView.View Binding=\"{Binding CurrentView, Converter={StaticResource ViewIsGridViewConverter}, Mode=OneWay}\" />","handlingStrategy":"validation","validationCode":"if (binding.Mode != BindingMode.OneWay)\n    throw new InvalidOperationException(\"ViewIsGridViewConverter supports only OneWay bindings.\");","typeGuard":"static bool IsGridView(object? v) => v is GridView;","tryCatchPattern":"try { ApplyBinding(); }\ncatch (NotSupportedException) { log.LogError(\"ViewIsGridViewConverter does not support ConvertBack\"); }","preventionTips":["Keep ListView.View bindings one-way.","Check converter exception type (NotSupported vs NotImplemented) when diagnosing.","Prefer explicit Mode in all theme style setters."],"tags":["wpf","converter","data-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-21T21:30:21.729Z"}