using System;
using System.Globalization;
using Avalonia.Data.Converters;
namespace Avalonia.PropertyGrid.Controls;
///
/// Converts boolean value to its negation for two-way binding
///
public sealed class NegateBoolConverter : IValueConverter
{
///
/// Converts a boolean value to its negation.
///
/// The boolean value to convert.
/// The target type.
/// Optional parameter.
/// Culture information.
/// The negated boolean value.
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is bool boolValue)
{
return !boolValue;
}
return false;
}
///
/// Converts a boolean value back to its negation (two-way binding).
///
/// The boolean value to convert back.
/// The target type.
/// Optional parameter.
/// Culture information.
/// The negated boolean value.
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is bool boolValue)
{
return !boolValue;
}
return false;
}
}