stride3d/stride · error · ArgumentException
The parameter of this converter must be an instance of the…
Error message
The parameter of this converter must be an instance of the Thickness structure. Use {sd:Thickness (arguments)} to construct one. What it means
NumericToThickness requires the ConverterParameter to be a WPF System.Windows.Thickness, whose four sides are each scaled by the numeric bound value. If the parameter is null or not a Thickness (e.g. a plain string), this ArgumentException is thrown. The message recommends the {sd:Thickness (arguments)} markup extension for constructing the parameter in XAML.
Solutions
- Set ConverterParameter="{sd:Thickness left, top, right, bottom}" in XAML
- Or supply a Thickness resource/static as the parameter
- Confirm the converter is NumericToThickness and the parameter type matches (Thickness, not Size or string)
- Move parameter construction into code-behind/view model if markup extensions are unavailable
Example fix
// before
Converter="{sd:NumericToThickness}" ConverterParameter="5,5,5,5"
// after
Converter="{sd:NumericToThickness}" ConverterParameter="{sd:Thickness 5,5,5,5}" Defensive patterns
Strategy: type-guard
Validate before calling
bool IsValidThicknessParameter(object parameter) => parameter is System.Windows.Thickness;
Type guard
bool IsThickness(object p) => p is System.Windows.Thickness;
Try / catch
try
{
return converter.Convert(value, typeof(Thickness), parameter, culture);
}
catch (ArgumentException)
{
return new Thickness(0);
} Prevention
- Use ConverterParameter="{sd:Thickness left, top, right, bottom}" in XAML
- Do not pass raw strings or Size instances as the parameter
- Double-check the converter/parameter pairing when copy-pasting from NumericToSize usages
- Prefer Thickness resources over literal string parameters
When it happens
Trigger: ConverterParameter="10" or "10,10,10,10" (strings) instead of a Thickness instance; parameter omitted so it is null; passing a Size parameter to NumericToThickness by copy-paste mistake.
Common situations: Migrating from NumericToSize and reusing a string parameter; XAML tooling that only emits primitive parameters; misunderstanding that the parameter must be a struct instance, not text.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- The parameter of this converter must be an instance of the…
- The value of this converter must be convertible to a double.
- The value of the ConvertBack method of this converter must…
- 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/58988538c8043e18.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/NumericToThickness.cs:36
public class NumericToThickness : ValueConverterBase<NumericToThickness>
{
/// <inheritdoc/>
[NotNull]
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
double scalar;
try
{
scalar = ConverterHelper.ConvertToDouble(value, culture);
}
catch (Exception exception)
{
throw new ArgumentException("The value of this converter must be convertible to a double.", exception);
}
if (!(parameter is Thickness))
{
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.");
}View on GitHub (pinned to 96fad776d2)