32 lines
1.0 KiB
C#
32 lines
1.0 KiB
C#
using System.Globalization;
|
|
using System.Windows.Data;
|
|
|
|
namespace Melskin.Converters;
|
|
|
|
/// <summary>
|
|
/// 比较两个值是否相等的多值转换器。
|
|
/// </summary>
|
|
public class ComparisionConverter : IMultiValueConverter
|
|
{
|
|
/// <summary>
|
|
/// ComparisionConverter 类的唯一实例,用于比较两个值是否相等。此静态实例遵循单例模式,确保在整个应用程序中仅创建一次该转换器对象。
|
|
/// </summary>
|
|
public static readonly ComparisionConverter Instance = new();
|
|
|
|
/// <inheritdoc />
|
|
public object Convert(object[]? values, System.Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (values == null || values.Length < 2 || values.Any(v => v == null || v == DependencyProperty.UnsetValue))
|
|
{
|
|
return false;
|
|
}
|
|
return values[0].Equals(values[1]);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public object[] ConvertBack(object value, System.Type[] targetTypes, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|