stride3d/stride · error · ArgumentException
{nameof(value)} is not a numeric type
Error message
{nameof(value)} is not a numeric type What it means
NumericToBool converts a numeric value to a bool (true when non-zero, per its parameter logic). It explicitly pattern-matches the supported numeric types (int, long, byte, ushort, uint, ulong, etc.) and throws this ArgumentException when the incoming value matches none of them. It deliberately does not attempt arbitrary conversions, so non-numeric objects like strings, doubles outside its handled set, or control objects fail fast.
Solutions
- Bind a property that is one of the supported numeric types (int, long, byte, ushort, uint, ulong, etc.)
- Place a prior converter (e.g. string-to-number) or use StringFormat/parsing in the view model before this converter
- Check which types your Stride version's NumericToBool handles and align the bound type
- Convert the value to a supported numeric type in the view model
Example fix
// before
public string Count { get; set; } // bound through NumericToBool
// after
public int Count { get; set; } // supported numeric type Defensive patterns
Strategy: type-guard
Validate before calling
bool IsSupportedNumeric(object v) =>
v is sbyte || v is byte || v is short || v is ushort || v is int || v is uint || v is long || v is ulong; Type guard
bool IsNumericForNumericToBool(object v) =>
v is sbyte || v is byte || v is short || v is ushort || v is int || v is uint || v is long || v is ulong; Try / catch
try
{
return converter.Convert(value, typeof(bool), parameter, culture);
}
catch (ArgumentException)
{
return false.Box(); // or a safe default
} Prevention
- Bind only typed numeric properties (int, long, byte, ushort, uint, ulong) to this converter
- Never bind string properties directly; parse in the view model first
- Check the handled type list in your Stride version before relying on exotic numeric types
- Add unit tests that call Convert with the exact types your bindings produce
When it happens
Trigger: Binding a non-numeric value (string, enum, object, double if not in the handled list) into a Binding whose Converter is NumericToBool, or calling Convert directly with such a value.
Common situations: Binding a string property from a TextBox directly through the converter; after a model refactor a numeric property became a string or nullable type not matched; passing an enum value expecting truthiness conversion.
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 parameter of the ConvertBack method of this converter mu
- The value of the ConvertBack method of this converter must b
- The parameter of the ConvertBack method of this converter mu
- The value of the ConvertBack method of this converter must b
- The parameter of the ConvertBack method of this converter mu
AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14).
Data as JSON: /api/errors/18e7a654f5fe195e.
Report an issue: GitHub.
Appendix: source
Thrown at sources/presentation/Stride.Core.Presentation.Wpf/ValueConverters/NumericToBool.cs:28
/// This converter will convert a numerical value to a boolean. The result will be <c>false</c> if the given value is equal to zero, <c>true</c> otherwise.
/// </summary>
/// <remarks>Supported types are: <see cref="SByte"/>, <see cref="Int16"/>, <see cref="Int32"/>, <see cref="Int64"/>, <see cref="Byte"/>, <see cref="UInt16"/>, <see cref="UInt32"/>, <see cref="UInt64"/></remarks>
public class NumericToBool : OneWayValueConverter<NumericToBool>
{
/// <inheritdoc/>
public override object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
bool result;
if (value is sbyte) result = (sbyte)value != 0;
else if (value is short) result = (short)value != 0;
else if (value is int) result = (int)value != 0;
else if (value is long) result = (long)value != 0;
else if (value is byte) result = (byte)value != 0;
else if (value is ushort) result = (ushort)value != 0;
else if (value is uint) result = (uint)value != 0;
else if (value is ulong) result = (ulong)value != 0;
else
throw new ArgumentException($"{nameof(value)} is not a numeric type");
return result.Box();
}
}
}
View on GitHub (pinned to 96fad776d2)