HuNan_DM_MultiBatch/DM_Weight/Converter/GroupSumConverter.cs

41 lines
1.1 KiB
C#
Raw Normal View History

2023-11-13 14:00:30 +08:00
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;
using DM_Weight.Models;
namespace DM_Weight.Converter
{
public class GroupSumConverter : IValueConverter
{
#region
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
var total = 0;
// DataGrid分组后对应的组及组内元素CollectionViewGroup.Items 类型是ReadOnlyObservableCollection<object>
if (value is ReadOnlyObservableCollection<object> items)
{
foreach (var item in items)
{
var de = item as ChannelStock;
total += de.Quantity;
}
}
return "总库存:" + total;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
#endregion
}
}