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 WPF.GrouedEdit
{
	/// <summary>
	/// Interaction logic for Window1.xaml
	/// </summary>
	public partial class Window1 : Window
	{
		public Window1()
		{
			InitializeComponent();

			NorthwindDataSetTableAdapters.CarsTableAdapter ad = new WPF.GrouedEdit.NorthwindDataSetTableAdapters.CarsTableAdapter();

			NorthwindDataSet ds = new NorthwindDataSet();

			ad.Fill(ds.Cars);

			SampleGrid.ItemsSource = ds;
			SampleGrid.AutoGeneratingColumn += new EventHandler<Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs>(SampleGrid_AutoGeneratingColumn);
		}

		void SampleGrid_AutoGeneratingColumn(object sender, Telerik.Windows.Controls.GridViewAutoGeneratingColumnEventArgs e)
		{
			e.Column.SourceUpdated += new EventHandler<DataTransferEventArgs>(Column_SourceUpdated);
		}

		void Column_SourceUpdated(object sender, DataTransferEventArgs e)
		{
			MessageBox.Show("Source updated");
		}

		private void Button_Click(object sender, RoutedEventArgs e)
		{
			SampleGrid.GroupDescriptors.Add(
				new GroupDescriptor()
				{
					Member = "Id",
					MemberType = typeof(int)
				});
		}
	}
}
