using System; using System.Globalization; using System.Windows.Data; namespace BBWY.Client.Converters { public class ProfitRatioConverter : IMultiValueConverter { public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture) { decimal.TryParse(values[0]?.ToString(), out decimal profit); decimal.TryParse(values[1]?.ToString(), out decimal totalCost); return totalCost == 0 ? "0" : Math.Round(profit / totalCost * 100, 2).ToString(); } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }