2023-12-30 15:50:37 +00:00
|
|
|
|
using System.Globalization;
|
2023-12-18 14:53:56 +00:00
|
|
|
|
|
2023-12-30 15:50:37 +00:00
|
|
|
|
namespace HKW.WPF.Converters;
|
2023-12-18 14:53:56 +00:00
|
|
|
|
|
2023-12-30 15:50:37 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 相等转换器
|
|
|
|
|
/// <para>示例:
|
|
|
|
|
/// <code><![CDATA[
|
|
|
|
|
/// <MultiBinding Converter="{StaticResource RatioMarginConverter}">
|
|
|
|
|
/// <Binding Path="Value1" />
|
|
|
|
|
/// <Binding Path="Value2" />
|
|
|
|
|
/// </MultiBinding>
|
|
|
|
|
/// ]]></code></para>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public class EqualsConverter : CanInverterMultiValueConverter<EqualsConverter>
|
2023-12-18 14:53:56 +00:00
|
|
|
|
{
|
2023-12-30 15:50:37 +00:00
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="values"></param>
|
|
|
|
|
/// <param name="targetType"></param>
|
|
|
|
|
/// <param name="parameter"></param>
|
|
|
|
|
/// <param name="culture"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
/// <exception cref="NotImplementedException"></exception>
|
|
|
|
|
public override object Convert(
|
2023-12-18 14:53:56 +00:00
|
|
|
|
object[] values,
|
|
|
|
|
Type targetType,
|
|
|
|
|
object parameter,
|
2023-12-30 15:50:37 +00:00
|
|
|
|
CultureInfo culture
|
2023-12-18 14:53:56 +00:00
|
|
|
|
)
|
|
|
|
|
{
|
|
|
|
|
if (values.Length != 2)
|
|
|
|
|
throw new NotImplementedException("Values length must be 2");
|
2023-12-30 15:50:37 +00:00
|
|
|
|
return values[0].Equals(values[1]) ^ Inverter;
|
2023-12-18 14:53:56 +00:00
|
|
|
|
}
|
|
|
|
|
}
|