stride3d/stride · error · ArgumentException
The parameter of the ConvertBack method of this converter…
Error message
The parameter of the ConvertBack method of this converter must be a an instance of the Thickness structure.
What it means
NumericToThickness.ConvertBack requires both the value and the parameter to be WPF Thickness instances because it multiplies each thickness component by a scalar derived from the parameter. The library throws ArgumentException to fail fast when a caller passes a value or parameter of any other type instead of silently producing a wrong thickness.
Solutions
- Pass a System.Windows.Thickness instance (or a Thickness that the XAML parser creates, e.g. '2') as ConverterParameter in the ConvertBack path.
- Ensure the value passed to ConvertBack is also a Thickness; convert scalars on the value side instead.
- If the binding is one-way, switch to OneWayValueConverter-style usage so ConvertBack is never invoked.
Example fix
// before binding.ConverterParameter = 2.0; // double -> throws // after binding.ConverterParameter = new System.Windows.Thickness(2);
Defensive patterns
Strategy: type-guard
Validate before calling
bool ok = value is System.Windows.Thickness && parameter is System.Windows.Thickness;
Type guard
static bool IsThicknessPair(object value, object parameter) => value is System.Windows.Thickness && parameter is System.Windows.Thickness;
Try / catch
try { return converter.ConvertBack(value, targetType, parameter, culture); }
catch (ArgumentException ex) { /* log ex.ParamName, fall back to original value */ return value; } Prevention
- Always pass a Thickness as ConverterParameter for this converter
- Use Thickness resources or constructor calls in XAML rather than bare numbers
- Keep two-way and one-way converters in separate instances/resources
When it happens
Trigger: Calling NumericToThickness.ConvertBack(value, targetType, parameter, culture) where parameter (or value) is not a System.Windows.Thickness — e.g. passing a double, a string, a custom thickness-like struct, or a binding producing null.
Common situations: Wiring the same converter instance in both directions of a TwoWay binding without realizing ConvertBack demands a Thickness parameter; passing ConverterParameter='2.0' instead of a Thickness; copying usage from a similar converter like SumSize that expects Size.
Understand the failure class
Background: Type mismatch errors: IllegalArgumentException, TypeError and type guards across 150 open-source libraries — this error's family across 150 libraries.
Related errors
- is not a numeric type
- The value of the ConvertBack method of this converter must…
- The parameter of the ConvertBack method of this converter…
- The value of the ConvertBack method of this converter must…
- The parameter of the ConvertBack method of this converter…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/834c29569677c0a3.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/NumericToThickness.cs:53
{
throw new ArgumentException("The parameter of this converter must be an instance of the Thickness structure. Use {sd:Thickness (arguments)} to construct one.");
}
var thickness = (Thickness)parameter;
var result = new Thickness(thickness.Left * scalar, thickness.Top * scalar, thickness.Right * scalar, thickness.Bottom * scalar);
return result;
}
/// <inheritdoc/>
public override object ConvertBack(object value, [NotNull] Type targetType, object parameter, CultureInfo culture)
{
if (!(value is Thickness))
{
throw new ArgumentException("The value of the ConvertBack method of this converter must be a an instance of the Thickness structure.");
}
if (!(parameter is Thickness))
{
throw new ArgumentException("The parameter of the ConvertBack method of this converter must be a an instance of the Thickness structure.");
}
var thicknessValue = (Thickness)value;
var thicknessParameter = (Thickness)parameter;
var scalar = 0.0;
if (Math.Abs(thicknessParameter.Left) > double.Epsilon)
{
scalar = thicknessValue.Left / thicknessParameter.Left;
}
else if (Math.Abs(thicknessParameter.Right) > double.Epsilon)
{
scalar = thicknessValue.Right / thicknessParameter.Right;
}
else if (Math.Abs(thicknessParameter.Top) > double.Epsilon)
{
scalar = thicknessValue.Top / thicknessParameter.Top;
}
else if (Math.Abs(thicknessParameter.Bottom) > double.Epsilon)View on GitHub (pinned to 96fad776d2)