dotnet/wpf · error · NotImplementedException

NotImplementedException

Error message

NotImplementedException

What it means

BooleanToSelectiveScrollingOrientationConverter.ConvertBack is intentionally not implemented; the converter is one-way only for DataGrid selective scrolling bindings. Any two-way binding that tries to convert back throws NotImplementedException.

Solutions

  1. Set the binding Mode explicitly to OneWay
  2. Write a custom IValueConverter that implements ConvertBack if reverse conversion is needed
  3. Do not use this converter for two-way scenarios

Example fix

// before
new Binding("IsSelective") { Converter = new BooleanToSelectiveScrollingOrientationConverter() };
// after
new Binding("IsSelective") { Converter = new BooleanToSelectiveScrollingOrientationConverter(), Mode = BindingMode.OneWay };
Defensive patterns

Strategy: type-guard

Type guard

bool IsOneWayBinding(Binding b) => b.Mode == BindingMode.OneWay || b.Mode == BindingMode.Default;

Try / catch

try
{
    var result = converter.ConvertBack(value, targetType, parameter, culture);
}
catch (NotImplementedException)
{
    // write custom converter for reverse mapping
}

Prevention

When it happens

Trigger: Binding BooleanToSelectiveScrollingOrientationConverter in a TwoWay or OneWayToSource binding; calling ConvertBack directly in code.

Common situations: Using the converter as a resource shared with other bindings that default to TwoWay; applying it to a Bindings collection in DataGrid with Mode=TwoWay.

Related errors


AI-assisted analysis of dotnet/wpf@81131a70a4 (2026-09-14). Data as JSON: /api/errors/8a379540dfa9641e. Report an issue: GitHub.

Appendix: source

Thrown at src/Microsoft.DotNet.Wpf/src/PresentationFramework/System/Windows/Controls/BooleanToSelectiveScrollingOrientationConverter.cs:44

            {
                var valueAsBool = (bool)value;
                var parameterSelectiveScrollingOrientation = (SelectiveScrollingOrientation)parameter;

                if (valueAsBool)
                {
                    return parameterSelectiveScrollingOrientation;
                }
            }

            return SelectiveScrollingOrientation.Both;
        }

        /// <summary>
        ///     Not implemented
        /// </summary>
        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}

View on GitHub (pinned to 81131a70a4)