Add convert back implementation for InverseBoolConverter

This commit is contained in:
Jack251970 2025-09-05 19:02:11 +08:00
parent cdf3905a51
commit 33aef7eb54

View file

@ -9,14 +9,17 @@ public class InverseBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (targetType != typeof(bool))
throw new InvalidOperationException("The target must be a boolean");
if (value is not bool)
throw new ArgumentException("value should be boolean", nameof(value));
return !(bool)value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotSupportedException();
if (value is not bool)
throw new ArgumentException("value should be boolean", nameof(value));
return !(bool)value;
}
}