autosos-maui/Converters/BoolNegationConverter.cs

21 lines
601 B
C#

using System.Globalization;
namespace autosos_maui.Converters;
public class BoolNegationConverter: IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
if (value is bool boolValue)
{
return !boolValue; // 返回布尔值的相反值
}
return value; // 返回原始值(或者你可以返回默认的可见性)
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}