Hallo,
I have a problem with writing a custom aggregate function. I have a Grid View, which groups the items. I can use the aggregate function to count how many items are in a group. I want to write a custom aggregate function to count how many selected items out of the existing items are there. I have an example that succeeds. But in my code comes to a Managed Runtime Error, while attempting to add the custom aggregate function to the column.
The custom function:
The error comes when this code is executed:
I have a problem with writing a custom aggregate function. I have a Grid View, which groups the items. I can use the aggregate function to count how many items are in a group. I want to write a custom aggregate function to count how many selected items out of the existing items are there. I have an example that succeeds. But in my code comes to a Managed Runtime Error, while attempting to add the custom aggregate function to the column.
The custom function:
Imports
System.Collections.Generic
Imports
Telerik.Windows.Data
Namespace
Views.Inverter
Public
Class
CountSelectedItemsFunction
Inherits
EnumerableSelectorAggregateFunction
Protected
Overrides
ReadOnly
Property
AggregateMethodName()
As
String
Get
Return
"CountSelected"
End
Get
End
Property
Protected
Overrides
ReadOnly
Property
ExtensionMethodsType()
As
Type
Get
Return
GetType
(CountSelectedItems)
End
Get
End
Property
End
Class
Public
NotInheritable
Class
CountSelectedItems
Private
Sub
New
()
End
Sub
Public
Shared
Function
CountSelected(Of TSource)(source
As
IEnumerable(Of TSource), selector
As
Func(Of TSource,
Integer
))
As
Integer
Dim
itemCount
As
Integer
= source.Count()
Return
1
End
Function
End
Class
End
Namespace
The error comes when this code is executed:
this.RadGridView1.Columns[1].AggregateFunctions.Add(new CountSelectedItemsFunction { SourceField = "intValue", ResultFormatString = "Int: {0}"});
I use the MVVM pattern. Could you please help me?