using System.Globalization;
using System.Windows;
using System.Windows.Data;
namespace YY.Admin.Core.Converter
{
///
/// 将枚举值转换为Visibility
///
public class EnumToVisibilityConverter : IValueConverter
{
///
/// 将枚举值转换为 Visibility
///
/// 绑定的枚举值
///
/// ConverterParameter 指定要匹配的枚举值
///
/// 匹配返回Visible
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null || parameter == null)
return Visibility.Collapsed;
return value.ToString()!.Equals(parameter.ToString(), StringComparison.OrdinalIgnoreCase)
? Visibility.Visible
: Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
=> throw new NotImplementedException();
}
}