stride3d/stride · error · NotSupportedException

ConvertBack is not supported with this ValueConverter.

Error message

ConvertBack is not supported with this ValueConverter.

What it means

OneWayValueConverter<T> is the single-value counterpart of OneWayMultiValueConverter: a base for converters that deliberately do not support reverse conversion. Its sealed ConvertBack always throws NotSupportedException with this message to signal the converter is being used in a direction it was never designed for.

Solutions

  1. Set Mode=OneWay on the binding.
  2. Implement a real ConvertBack by deriving from ValueConverterBase directly instead of OneWayValueConverter.
  3. Use a two-way-capable converter for editable fields.

Example fix

// before
<TextBlock Text="{Binding Count, Converter={StaticResource Double}}" /> <!-- bound to editable TextBox, TwoWay -->
// after
<TextBox Text="{Binding Count, Mode=OneWay, Converter={StaticResource Double}}" />
Defensive patterns

Strategy: validation

Validate before calling

if (binding is { } b && converter is OneWayValueConverter<IValueConverter>) b.Mode = BindingMode.OneWay;

Type guard

static bool IsOneWayOnly(IValueConverter c) => c.GetType().BaseType?.GetGenericTypeDefinition() == typeof(OneWayValueConverter<>);

Try / catch

try { return converter.ConvertBack(value, targetType, parameter, culture); }
catch (NotSupportedException) { return Binding.DoNothing; }

Prevention

When it happens

Trigger: Binding with Mode=TwoWay or OneWayToSource to any converter deriving from OneWayValueConverter<T>, causing WPF to call ConvertBack on the sealed override.

Common situations: Attaching a display-only converter (bool->Visibility, numeric formatting) to an editable control whose default binding mode is TwoWay; copy-pasted XAML from a TwoWay binding; WPF defaults TextBox.Text to TwoWay so the converter's ConvertBack is invoked on every UI edit.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/37eeefa46158aea9. Report an issue: GitHub.

Appendix: source

Thrown at sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/OneWayValueConverter.cs:19

// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)
// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.
using System;
using System.Globalization;
using System.Windows.Data;

namespace Stride.Core.Presentation.ValueConverters
{
    /// <summary>
    /// An abstract implementation of <see cref="ValueConverterBase{T}"/> that does not support <see cref="ConvertBack"/>.
    /// Invoking <see cref="ConvertBack"/> on this value converter will throw a <see cref="NotSupportedException"/>.
    /// </summary>
    /// <typeparam name="T">The type of <see cref="IValueConverter"/> being implemented.</typeparam>
    public abstract class OneWayValueConverter<T> : ValueConverterBase<T> where T : class, IValueConverter, new()
    {
        /// <inheritdoc/>
        public sealed override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException("ConvertBack is not supported with this ValueConverter.");
        }
    }
}

View on GitHub (pinned to 96fad776d2)