简单实现变量的历史记录功能

This commit is contained in:
2025-07-16 20:54:38 +08:00
parent b596887f6e
commit 28c2754d53
5 changed files with 185 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
using System;
using System.Globalization;
using System.Windows.Data;
namespace PMSWPF.ValueConverts
{
public class NullableBooleanConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool b && parameter is string paramString)
{
if (bool.TryParse(paramString, out bool paramBool))
{
return b == paramBool;
}
}
return Binding.DoNothing;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value is bool b && b && parameter is string paramString)
{
if (bool.TryParse(paramString, out bool paramBool))
{
return paramBool;
}
}
return Binding.DoNothing;
}
}
}