demo_trade/UI/Converters/ItemColorOrderConverter.cs

29 lines
866 B
C#
Raw Permalink Normal View History

2024-10-04 12:41:04 +00:00
using Avalonia.Data.Converters;
using Avalonia.Media;
using demo_trade.Data.RemoteData.Entity;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace demo_trade.UI.Converters
{
public class ItemColorOrderConverter : IValueConverter
{
public object? Convert(object? value, Type targetType, object? parameter, CultureInfo culture)
{
var products = (List<Product>)value;
return products.Where(it => it.Productquantityinstock < 3).ToList().Count > 0 ? new SolidColorBrush(Colors.Yellow) : new SolidColorBrush(Colors.White);
}
public object? ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture)
{
throw new NotSupportedException();
}
}
}