using System.Globalization; using System.Windows.Data; namespace NeoUI.Converters; /// /// 隔行交错背景颜色 /// [ValueConversion(typeof(int), typeof(Visibility))] public class InterlacedBackgroundConverter : IValueConverter { public static readonly InterlacedBackgroundConverter Instance = new(); /// public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) { var line = (int)(value ?? throw new ArgumentNullException(nameof(value))); return line % 2 == 0 ? Visibility.Collapsed : Visibility.Visible; } /// public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) { return Binding.DoNothing; } }