/// <summary>
/// Converts a <see cref="bool"/> value to a <see cref="Visibility"/> enumeration value.
/// </summary>
/// <param name="value">The <see cref="bool"/> value to convert. This can also be a <see cref="Nullable{Boolean}"/> value.</param>
/// <param name="targetType">This parameter is not used.</param>
/// <param name="parameter">This parameter is not used.</param>
/// <param name="culture">This parameter is not used.</param>
/// <returns>Returns <see cref="Visibility.Collapsed"/> if the value is true, otherwise <see cref="Visibility.Visible"/>.</returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool?)
{
if (true == (bool?)value)
{
value = false;
}
else
{
value = true;
}
//var inverseValue = ((bool?)value).HasValue ? !((bool)value);
return(converter.Convert(value, targetType, parameter, culture));
}
else if (value is bool)
{
var inverseValue = !((bool)value);
return(converter.Convert(inverseValue, targetType, parameter, culture));
}
else
{
throw new InvalidOperationException("The value parameter must be of type System.Boolean.");
}
}