Handle null as a valid boolean value in BoolToVisibilityConverter.

This commit is contained in:
Adrien Allard committed 2019-07-31 08:43:05 +02:00
1 parent cb7760e7cc
commit fbcc910f94
1 file changed
+3 -2
@@ -10,11 +10,13 @@ namespace FileConverter.ValueConverters.Generic
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is bool))
if (value != null && !(value is bool))
{
throw new ArgumentException("The value must be a boolean.");
}
bool booleanValue = (bool?) value ?? false;
string stringParameter = parameter as string;
string trueResult = "Visible";
@@ -35,7 +37,6 @@ namespace FileConverter.ValueConverters.Generic
}
}
bool booleanValue = (bool)value;
return booleanValue ? trueResult : falseResult;
}