autosos-maui/Converters/BoolNegationConverter.cs

21 lines
601 B
C#
Raw Permalink Normal View History

2023-12-29 17:37:14 +08:00
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();
}
}