36 lines
1.0 KiB
C#
36 lines
1.0 KiB
C#
using DM_Weight.Models;
|
|
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;
|
|
|
|
namespace DM_Weight.Converter
|
|
{
|
|
public class TotalCountConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
var total = 0;
|
|
// DataGrid分组后对应的组及组内元素CollectionViewGroup.Items 类型是ReadOnlyObservableCollection<object>
|
|
if (value is List<ChannelStock> 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();
|
|
}
|
|
}
|
|
}
|