Files
ShrlAlgoToolkit/NeuWPF/NeoUI/Converters/Internal/InterlacedBackgroundConverter.cs

26 lines
799 B
C#
Raw Normal View History

2025-07-31 20:12:24 +08:00
using System.Globalization;
using System.Windows.Data;
2025-08-20 12:10:13 +08:00
namespace NeoUI.Converters;
2025-07-31 20:12:24 +08:00
/// <summary>
/// 隔行交错背景颜色
/// </summary>
[ValueConversion(typeof(int), typeof(Visibility))]
public class InterlacedBackgroundConverter : IValueConverter
{
public static readonly InterlacedBackgroundConverter Instance = new();
2025-08-20 12:10:13 +08:00
/// <inheritdoc />
2025-07-31 20:12:24 +08:00
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;
}
2025-08-20 12:10:13 +08:00
/// <inheritdoc />
2025-07-31 20:12:24 +08:00
public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
2025-08-20 12:10:13 +08:00
return Binding.DoNothing;
2025-07-31 20:12:24 +08:00
}
}