using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using Telerik.Windows.Data;

namespace GenericAggregateFunction_Sum_Total
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			InitializeComponent();
			this.myGrid.ItemsSource = MyItem.GetItems();

			var aggregateFunction = new AggregateFunction<MyItem, double>
			{
				AggregationExpression = myItem => (double)myItem.Sum(c => c.Number3)*100 / ((double)myItem.Sum(c => c.Number1) + (double)myItem.Sum(c => c.Number2) + (double)myItem.Sum(c => c.Number3)),
				Caption = "Total:", ResultFormatString = "{0:p0}"
			};

			this.myGrid.Columns["Number3"].AggregateFunctions.Add(aggregateFunction);



		}
	}
}
