添加项目文件。
This commit is contained in:
22
UIShare/Converters/InverseBooleanConverter.cs
Normal file
22
UIShare/Converters/InverseBooleanConverter.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Windows.Data;
|
||||
|
||||
namespace UIShare.Converters
|
||||
{
|
||||
public class InverseBooleanConverter : IValueConverter
|
||||
{
|
||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
// null 视为 false,再取反 → true
|
||||
var b = value as bool?;
|
||||
return !(b ?? false);
|
||||
}
|
||||
|
||||
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
||||
{
|
||||
var b = value as bool?;
|
||||
return !(b ?? false);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user