using System; using System.Globalization; using System.Windows.Data; namespace BBWY.Client.Converters { /// /// 销售毛利率转换器 /// public class SaleGrossProfitConverter : 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 actualAmount); return $"{(actualAmount == 0 ? 0M : Math.Round(profit / actualAmount * 100, 2))}%"; } public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }