mirror of
https://github.com/Tichau/FileConverter.git
synced 2026-11-19 09:01:32 +01:00
Handle null as a valid boolean value in BoolToVisibilityConverter.
This commit is contained in:
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;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user