I read the example : http://demos.telerik.com/silverlight/#GridView/CustomAggregates and defined a class like this:
using System;
using Telerik.Windows.Data;
using System.Collections.Generic;
using System.Linq;
namespace MSHF.Paris.UIPlatform.Common
{
public class ObjectSumFunction : EnumerableSelectorAggregateFunction
{
protected override string AggregateMethodName
{
get
{
return "Sum";
}
}
protected override Type ExtensionMethodsType
{
get
{
return typeof(ObjectSum);
}
}
}
public static class ObjectSum
{
public static object Sum<TSource>(IEnumerable<TSource> source, Func<TSource, object> selector)
{
int itemCount = source.Count();
if (itemCount > 0)
{
IEnumerable<decimal> values = from i in source select Convert.ToDecimal(selector(i));
return values.Sum();
}
return 0;
}
}
}
add the function in code:
dataColumn.AggregateFunctions.Add(new ObjectSumFunction()
{
Caption = "total:",
SourceField = "A4",
SourceFieldType = typeof(object),
ResultFormatString = gd.GridColumnDefinitions[i].DataFormat
});
the column type is object(in fact, it is a decimal, but converted to object)
Get the error:No generic method 'Sum' on type 'MSHF.Paris.UIPlatform.Common.ObjectSum' is compatible with the", because it is a Just-In-Time Debugger dialog, the message is trucated.
please see the attached error file.