using C1.Silverlight.DataGrid;
using C1.Silverlight.DataGrid.Summaries;
using System.Collections.Generic;

namespace C1DataGrid_Demo2010
{
    public partial class GrandTotal : System.Windows.Controls.UserControl
    {
        public GrandTotal()
        {
            InitializeComponent();
            grid.ItemsSource = Data.GetProducts(); // GetProducts()
        }


        private void grid_AutoGeneratingColumn(object sender, C1.Silverlight.DataGrid.DataGridAutoGeneratingColumnEventArgs e)
        {
            Common.HandleColumnAutoGeneration(e);

            if (e.Property.Name == "StandardCost")
            {
                DataGridAggregate.SetAggregateFunctions(e.Column,
                    new DataGridAggregatesCollection
                    { 
                        new DataGridAggregateSum { ResultFormat = "SUM = {0}" },
                        new DataGridAggregateAvg { ResultFormat = "AVG = {0}" },
                    });
            }
        }
    }
}
