unoplatform/uno · error · ArgumentException
Value must either be null or of type bool. Got {value} ({val
Error message
Value must either be null or of type bool. Got {value} ({value.GetType().FullName}) What it means
FromNullableBoolToReverseBoolConverter.Convert throws when value is non-null and not a bool, enforcing the nullable-bool-only contract before inverting.
Source
Thrown at src/SamplesApp/SamplesApp.UnitTests.Shared/Controls/UITests/Views/Converters/FromNullableBoolToReverseBoolConverter.cs:22
using System.Text;
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Data;
using Microsoft.UI.Xaml.Media;
namespace Uno.UI.Samples.Converters
{
public class FromNullableBoolToReverseBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
if (parameter != null)
{
throw new ArgumentException($"This converter does not use any parameters. You should remove \"{parameter}\" passed as parameter.");
}
if (value != null && !(value is bool))
{
throw new ArgumentException($"Value must either be null or of type bool. Got {value} ({value.GetType().FullName})");
}
var valueToConvert = value != null && System.Convert.ToBoolean(value, CultureInfo.InvariantCulture);
return !valueToConvert;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotSupportedException();
}
}
}
View on GitHub (pinned to 0418340488)
Solutions
- Bind to a bool / bool? source.
- Pre-convert with another converter if the source is non-bool.
- Check value.GetType().FullName in the message.
Example fix
<!-- before -->
{Binding Status, Converter={StaticResource Rev}}
<!-- after -->
{Binding IsActive, Converter={StaticResource Rev}} Defensive patterns
Strategy: type-guard
Validate before calling
if (value is not null and not bool) throw new ArgumentException("expected bool?"); Type guard
static bool IsNullableBool(object value) => value is null or bool;
Prevention
- Bind bool / bool? sources only.
- Use value.GetType().FullName from the message to diagnose.
When it happens
Trigger: Binding a non-bool source (int, enum, string, Visibility) to this reverse converter.
Common situations: Wrong binding path; source property type changed; value converter chain feeding an incompatible type.
Related errors
- Value must either be null or of type bool. Got {value} ({val
- Value must either be null or of type bool. Got {value} ({val
- Value must either be null or of type bool. Got {value} ({val
- This converter does not use any parameters. You should remov
- This converter does not use any parameters. You should remov
AI-assisted analysis of unoplatform/uno@0418340488 (2026-08-13).
Data as JSON: /api/errors/bb537b4ddce60790.
Report an issue: GitHub.