30 lines
712 B
C#
30 lines
712 B
C#
using System;
|
|
using System.Globalization;
|
|
using Avalonia.Data.Converters;
|
|
|
|
namespace Avalonia.PropertyGrid.Controls;
|
|
|
|
/// <summary>
|
|
/// Converts boolean value to its negation for two-way binding
|
|
/// </summary>
|
|
public class NegateBoolConverter : IValueConverter
|
|
{
|
|
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
if (value is bool boolValue)
|
|
{
|
|
return !boolValue;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
|
|
{
|
|
if (value is bool boolValue)
|
|
{
|
|
return !boolValue;
|
|
}
|
|
return false;
|
|
}
|
|
}
|