diff options
Diffstat (limited to 'win/CS/HandBrakeWPF/Converters/InverseBooleanConverter.cs')
-rw-r--r-- | win/CS/HandBrakeWPF/Converters/InverseBooleanConverter.cs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/win/CS/HandBrakeWPF/Converters/InverseBooleanConverter.cs b/win/CS/HandBrakeWPF/Converters/InverseBooleanConverter.cs index 8cd29431f..b935953eb 100644 --- a/win/CS/HandBrakeWPF/Converters/InverseBooleanConverter.cs +++ b/win/CS/HandBrakeWPF/Converters/InverseBooleanConverter.cs @@ -16,7 +16,7 @@ namespace HandBrakeWPF.Converters /// <summary>
/// The inverse boolean converter.
/// </summary>
- [ValueConversion(typeof(bool), typeof(bool))]
+ [ValueConversion(typeof(bool?), typeof(bool))]
public class InverseBooleanConverter : IValueConverter
{
/// <summary>
@@ -39,12 +39,14 @@ namespace HandBrakeWPF.Converters /// </returns>
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
- if (targetType != typeof(bool))
+ if (targetType != typeof(bool?) && targetType != typeof(bool))
{
throw new InvalidOperationException("The target must be a boolean");
}
- return !(bool)value;
+ bool result;
+ bool.TryParse(value.ToString(), out result);
+ return !result;
}
/// <summary>
@@ -67,7 +69,7 @@ namespace HandBrakeWPF.Converters /// </returns>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
- throw new NotSupportedException();
+ return null;
}
}
}
\ No newline at end of file |