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

			var dataCollection = new ObservableItemCollection<Person>();

			dataCollection.ItemChanged += new EventHandler<ItemChangedEventArgs<Person>>(dataCollection_ItemChanged);

			dataCollection.AddRange(
				from c in Enumerable.Range(0, 10)
				select new Person
				{
					Age = c + 15,
					Name = "Name" + c
				});

			this.DataContext = dataCollection;
		}

		void dataCollection_ItemChanged(object sender, ItemChangedEventArgs<Person> e)
		{
			//called on each modified data
			var person = e.Item;
			var modifiedInfo = e.PropertyName;

		}

		private void RadGridView_CellEditEnded(object sender, Telerik.Windows.Controls.GridViewCellEditEndedEventArgs e)
		{
			//called when end commiting data
			var data = e.Cell.Value;
		}

		private void RadGridView_CellValidated(object sender, Telerik.Windows.Controls.GridViewCellValidatedEventArgs e)
		{
			//called before committing modification
			var data = e.Cell.Value;
		}

		private void RadGridView_BeginningEdit(object sender, Telerik.Windows.Controls.GridViewBeginningEditRoutedEventArgs e)
		{
			//called when start editing data
			var data = e.Cell.Value;
		}
	}
}
