Skip to content

Instantly share code, notes, and snippets.

@Char0394
Created June 2, 2020 13:43
Show Gist options
  • Save Char0394/149480cbf12fa2f867e02f62798fb001 to your computer and use it in GitHub Desktop.
Save Char0394/149480cbf12fa2f867e02f62798fb001 to your computer and use it in GitHub Desktop.
public class InverseBoolConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (!(value is bool))
{
throw new InvalidOperationException("The target must be a boolean");
}
return !(bool)value;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
return null;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment