stride3d/stride · error · NotSupportedException

ConvertBack is not supported with this ValueConverter.

Error message

ConvertBack is not supported with this ValueConverter.

What it means

The internal value converter used by the Localize markup extension performs one-way conversion only (formatting a localized string, optionally with a count for pluralization). Converting a formatted, localized string back to the original source value is impossible, so ConvertBack throws NotSupportedException by design.

Solutions

  1. Use Mode=OneWay (the default) on bindings that use the Localize extension.
  2. For editable localized content, bind to your ViewModel string property directly and handle localization in the ViewModel, not via Localize markup.
  3. Write a custom IMultiValueConverter/IValueConverter that keeps the source key separately if reverse mapping is truly needed.

Example fix

// before
<TextBlock Text="{local:Localize MyKey, Mode=TwoWay}" />
// after
<TextBlock Text="{local:Localize MyKey}" /> <!-- one-way only -->
Defensive patterns

Strategy: validation

Validate before calling

<!-- ensure binding is one-way -->
<TextBlock Text="{local:Localize MyKey}" /> <!-- never Mode=TwoWay/OneWayToSource -->

Prevention

When it happens

Trigger: Binding with Mode=TwoWay (or OneWayToSource) whose converter is the one created inside LocalizeExtension's ProvideValue/LocalizeExtension.ValueConverter — any attempt by WPF/Avalonia binding to push the UI value back to the source.

Common situations: Two-way bindings on Text properties that use Localize; copy-pasting a OneWay binding and switching Mode to TwoWay to make an editable localized field; using Localize in a TextBox/EditContext setup.

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/710974859cf8efd5. Report an issue: GitHub.

Appendix: source

Thrown at sources/presentation/Stride.Core.Translation.Presentation/MarkupExtensions/LocalizeExtension.cs:135

                this.assembly = assembly;
                this.isStringFormat = isStringFormat;
            }

            /// <inheritdoc />
            [NotNull]
            public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
            {
                var count = value != DependencyProperty.UnsetValue ? System.Convert.ToInt32(value, culture) : default(int);
                var result = string.IsNullOrEmpty(context)
                    ? TranslationManager.Instance.GetPluralString(text, plural, count, assembly)
                    : TranslationManager.Instance.GetParticularPluralString(context, text, plural, count, assembly);
                return isStringFormat? string.Format(result, count) : result;
            }

            /// <inheritdoc />
            public 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)