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 Size structure.
What it means
SumSize.Convert's second validation throws ArgumentException when the converter parameter is not a System.Windows.Size; both operands must be Size so their Width/Height can be added. Like its sibling check, the message text says 'ConvertBack method' although it is raised inside Convert — a known copy/paste typo in the source.
Solutions
- Set ConverterParameter to a Size, e.g. in XAML pass a value the parser creates as Size or construct it in code: new Size(w,h).
- Create the parameter in code-behind or a resource with x:Type Size semantics.
- Use the scalar-appropriate converter if the parameter is a plain number.
Example fix
// before
<MultiBinding Converter="{StaticResource SumSize}" ConverterParameter="10" />
// after
binding.ConverterParameter = new System.Windows.Size(10, 10); Defensive patterns
Strategy: type-guard
Validate before calling
bool ok = parameter is System.Windows.Size;
Type guard
static bool IsSizeParameter(object parameter) => parameter is System.Windows.Size;
Try / catch
try { return sumSize.Convert(value, targetType, parameter, culture); }
catch (ArgumentException) { return Binding.DoNothing; } Prevention
- Set ConverterParameter to a Size instance, not a raw number
- Create parameters in code-behind or via resources when XAML parsing is ambiguous
- Use scalar converters for numeric parameters instead
- Beware the message text mentions ConvertBack although thrown from Convert
When it happens
Trigger: Invoking SumSize.Convert (or configuring the converter in XAML) with ConverterParameter that is not a Size — e.g. ConverterParameter='10' (parsed as string/double), a Thickness, or a binding-supplied non-Size object.
Common situations: Supplying numeric XAML parameters expecting scalar addition; copying parameter style from NumericToThickness converters; passing a Thickness where a Size is expected.
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
- The value of the ConvertBack method of this converter must…
- is not a numeric type
- The value of this converter must be convertible to a double.
- 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/1aec0bac8e1d9bba.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/SumSize.cs:28
{
/// <summary>
/// This converter will sum a given <see cref="Size"/> with a <see cref="Size"/> passed as parameter. You can use the <see cref="MarkupExtensions.SizeExtension"/>
/// markup extension to easily pass one, with the following syntax: {sd:Size (arguments)}.
/// </summary>
[ValueConversion(typeof(Size), typeof(Size))]
public class SumSize : ValueConverterBase<SumSize>
{
/// <inheritdoc/>
[NotNull]
public override object Convert(object value, 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.");
}
var sizeValue = (Size)value;
var sizeParameter = (Size)parameter;
var result = new Size(sizeValue.Width + sizeParameter.Width, sizeValue.Height + sizeParameter.Height);
return result;
}
/// <inheritdoc/>
[NotNull]
public override object ConvertBack(object value, 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))
{View on GitHub (pinned to 96fad776d2)