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 Size structure. Use {sd:Size (arguments)} to construct one. What it means
NumericToSize requires its ConverterParameter to be a WPF System.Windows.Size instance, which the converter scales by the numeric bound value. If the parameter is missing, is a string, or is any other type, this ArgumentException is thrown. The message points to the {sd:Size (arguments)} markup extension as the intended way to construct the parameter in XAML.
Solutions
- Declare the parameter with the sd:Size markup extension, e.g. ConverterParameter="{sd:Size 100, 50}"
- Or bind a Size resource/static value as ConverterParameter
- Verify you did not confuse NumericToSize with a converter that takes string parameters
- If the string form is unavoidable, wrap in a markup extension or convert to Size before binding
Example fix
// before
Converter="{sd:NumericToSize}" ConverterParameter="100,50"
// after
Converter="{sd:NumericToSize}" ConverterParameter="{sd:Size 100, 50}" Defensive patterns
Strategy: type-guard
Validate before calling
bool IsValidSizeParameter(object parameter) => parameter is System.Windows.Size;
Type guard
bool IsSize(object p) => p is System.Windows.Size size && !double.IsNaN(size.Width) && !double.IsNaN(size.Height);
Try / catch
try
{
return converter.Convert(value, typeof(Size), parameter, culture);
}
catch (ArgumentException)
{
return new Size(0, 0);
} Prevention
- Always construct the parameter with ConverterParameter="{sd:Size w, h}"
- Never pass raw strings like "100,50" as ConverterParameter for this converter
- Check parameter type at binding authoring time with a debug converter or trace output
- Prefer a Size resource (StaticResource) over string parameters
When it happens
Trigger: Using ConverterParameter="100,50" (a string) instead of a Size instance; omitting ConverterParameter entirely (parameter is null); passing a numeric or Thickness parameter by mistake to NumericToSize.
Common situations: Copy-pasting a converter usage from NumericToThickness and leaving a string parameter; authors unfamiliar with markup extensions passing raw XAML strings as parameters; tooling that only supports primitive ConverterParameter values.
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 value of this converter must be convertible to a double.
- The value of the ConvertBack method of this converter must…
- The parameter of the ConvertBack method of this converter…
- The parameter of this converter must be an instance of the…
- 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/b11b0c32e6adbc85.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/NumericToSize.cs:36
public class NumericToSize : ValueConverterBase<NumericToSize>
{
/// <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 Size))
{
throw new ArgumentException("The parameter of this converter must be an instance of the Size structure. Use {sd:Size (arguments)} to construct one.");
}
var size = (Size)parameter;
var result = new Size(size.Width * scalar, size.Height * scalar);
return result;
}
/// <inheritdoc/>
public override object ConvertBack(object value, [NotNull] Type targetType, object parameter, CultureInfo culture)
{
if (!(value is Size))
{
throw new ArgumentException("The value of the ConvertBack method of this converter must be a an instance of the Size structure.");
}
if (!(parameter is Size))
{
throw new ArgumentException("The parameter of the ConvertBack method of this converter must be a an instance of the Size structure.");
}View on GitHub (pinned to 96fad776d2)