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
SumThickness.Convert requires the ConverterParameter to be a Thickness so it can add Left/Top/Right/Bottom component-wise. It throws this ArgumentException from Convert (SumThickness.cs:28) when `parameter` is not a Thickness.
Solutions
- Supply the parameter as a Thickness resource: `<Thickness x:Key="Delta">1,2,3,4</Thickness>` then `ConverterParameter="{StaticResource Delta}"`.
- Set the converter parameter in code-behind/ViewModel as `new Thickness(...)`.
- Use a Binding (with a Thickness-typed source) instead of ConverterParameter.
- Guard with `if (parameter is Thickness)` before calling Convert.
Example fix
// before
<Border local:SumThickness.ConverterParameter="1,2,3,4" /> <!-- string, throws -->
// after
<sys:Thickness x:Key="Pad">1,2,3,4</sys:Thickness>
<Border local:SumThickness.ConverterParameter="{StaticResource Pad}" /> Defensive patterns
Strategy: type-guard
Validate before calling
bool ok = parameter is System.Windows.Thickness;
Type guard
static bool HasValidParameter(object p) => p is System.Windows.Thickness;
Try / catch
try { return converter.Convert(value, typeof(Thickness), param, culture); }
catch (ArgumentException) { return Binding.DoNothing; } Prevention
- Use <Thickness> resources for ConverterParameter instead of strings.
- Remember XAML ConverterParameter attributes can only yield strings — never a Thickness.
- Prefer MultiBinding or a dedicated converter if you need string-parsed offsets.
When it happens
Trigger: Setting ConverterParameter to a string like "1,2,3,4" or a double in XAML while using SumThickness in a forward (Convert) binding; calling Convert directly with a non-Thickness parameter.
Common situations: XAML ConverterParameter only produces strings, so this throws for nearly every XAML-based usage unless a Size/Thickness resource is supplied; copying patterns from converters that parse string parameters.
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 parameter of this converter must be an instance of the…
- The parameter of this converter must be an instance of the…
- The parameter of the ConvertBack method of this converter…
- The value of the ConvertBack method of this converter must…
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/38422323fec4acf7.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/SumThickness.cs:28
{
/// <summary>
/// This converter will sum a given <see cref="Thickness"/> with a <see cref="Thickness"/> passed as parameter. You can use
/// the <see cref="MarkupExtensions.ThicknessExtension"/> markup extension to easily pass one, with the following syntax: {sd:Thickness (arguments)}.
/// </summary>
[ValueConversion(typeof(Thickness), typeof(Thickness))]
public class SumThickness : ValueConverterBase<SumThickness>
{
/// <inheritdoc/>
[NotNull]
public override object Convert(object value, 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 sizeValue = (Thickness)value;
var sizeParameter = (Thickness)parameter;
var result = new Thickness(sizeValue.Left + sizeParameter.Left, sizeValue.Top + sizeParameter.Top, sizeValue.Right + sizeParameter.Right, sizeValue.Bottom + sizeParameter.Bottom);
return result;
}
/// <inheritdoc/>
[NotNull]
public override object ConvertBack(object value, 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))
{View on GitHub (pinned to 96fad776d2)