25 lines
763 B
C#
25 lines
763 B
C#
using System;
|
|
using System.Globalization;
|
|
using System.Windows.Data;
|
|
|
|
namespace XplorePlane.Converters
|
|
{
|
|
/// <summary>
|
|
/// 布尔值取反转换器,用于将 true 转为 false、false 转为 true
|
|
/// Inverse boolean converter: converts true to false and false to true
|
|
/// </summary>
|
|
[ValueConversion(typeof(bool), typeof(bool))]
|
|
public class InverseBoolConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
return value is bool b ? !b : true;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
return value is bool b ? !b : false;
|
|
}
|
|
}
|
|
}
|