demo_trade/UI/Converters/ItemColorOrderConverter.cs
2024-10-04 15:41:04 +03:00

29 lines
866 B
C#

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();
}
}
}