{"record":{"id":"37eeefa46158aea9","repo":"stride3d/stride","slug":"convertback-is-not-supported-with-this-valueconverter-37eeef","errorCode":null,"errorMessage":"ConvertBack is not supported with this ValueConverter.","messagePattern":"ConvertBack is not supported with this ValueConverter\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/OneWayValueConverter.cs","lineNumber":19,"sourceCode":"// Copyright (c) .NET Foundation and Contributors (https://dotnetfoundation.org/ & https://stride3d.net) and Silicon Studio Corp. (https://www.siliconstudio.co.jp)\n// Distributed under the MIT license. See the LICENSE.md file in the project root for more information.\nusing System;\nusing System.Globalization;\nusing System.Windows.Data;\n\nnamespace Stride.Core.Presentation.ValueConverters\n{\n    /// <summary>\n    /// An abstract implementation of <see cref=\"ValueConverterBase{T}\"/> that does not support <see cref=\"ConvertBack\"/>.\n    /// Invoking <see cref=\"ConvertBack\"/> on this value converter will throw a <see cref=\"NotSupportedException\"/>.\n    /// </summary>\n    /// <typeparam name=\"T\">The type of <see cref=\"IValueConverter\"/> being implemented.</typeparam>\n    public abstract class OneWayValueConverter<T> : ValueConverterBase<T> where T : class, IValueConverter, new()\n    {\n        /// <inheritdoc/>\n        public sealed override object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)\n        {\n            throw new NotSupportedException(\"ConvertBack is not supported with this ValueConverter.\");\n        }\n    }\n}\n","sourceCodeStart":1,"sourceCodeEnd":23,"githubUrl":"https://github.com/stride3d/stride/blob/96fad776d210c221682aac1ccdf4c79dc046fc38/sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/OneWayValueConverter.cs#L1-L23","documentation":"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.","triggerScenarios":"Binding with Mode=TwoWay or OneWayToSource to any converter deriving from OneWayValueConverter<T>, causing WPF to call ConvertBack on the sealed override.","commonSituations":"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.","solutions":["Set Mode=OneWay on the binding.","Implement a real ConvertBack by deriving from ValueConverterBase directly instead of OneWayValueConverter.","Use a two-way-capable converter for editable fields."],"exampleFix":"// before\n<TextBlock Text=\"{Binding Count, Converter={StaticResource Double}}\" /> <!-- bound to editable TextBox, TwoWay -->\n// after\n<TextBox Text=\"{Binding Count, Mode=OneWay, Converter={StaticResource Double}}\" />","handlingStrategy":"validation","validationCode":"if (binding is { } b && converter is OneWayValueConverter<IValueConverter>) b.Mode = BindingMode.OneWay;","typeGuard":"static bool IsOneWayOnly(IValueConverter c) => c.GetType().BaseType?.GetGenericTypeDefinition() == typeof(OneWayValueConverter<>);","tryCatchPattern":"try { return converter.ConvertBack(value, targetType, parameter, culture); }\ncatch (NotSupportedException) { return Binding.DoNothing; }","preventionTips":["Set Mode=OneWay for display-only converters","Do not attach one-way converters to editable controls with TwoWay defaults","Derive from ValueConverterBase directly when you need ConvertBack","Audit XAML bindings after copy-paste for leftover Mode attributes"],"tags":["wpf","valueconverter","notsupported","binding"],"backgroundTag":"unsupported-operation","analyzedSha":"96fad776d210c221682aac1ccdf4c79dc046fc38","analyzedAt":"2026-09-14T02:59:31.279Z","contentChangedAt":"2026-09-14T02:59:31.279Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}