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.Controls;
using System.Diagnostics;

namespace ComboBox_Selection_Changed_Handling_WPF
{
	/// <summary>
	/// Interaction logic for Window1.xaml
	/// </summary>
	public partial class Window1 : Window
	{
		public Window1()
		{
			InitializeComponent();
			this.RadGridView1.ItemsSource = Person.GetSampleListOfPersons();
			((GridViewComboBoxColumn) this.RadGridView1.Columns[0]).ItemsSource = this.GetCountries();
		}

		private List<Country> GetCountries()
		{
			List<Country> countries = new List<Country>();
			countries.Add(new Country() { ID = 1, Name = "USA" });
			countries.Add(new Country() { ID = 2, Name = "Canada" });
			countries.Add(new Country() { ID = 3, Name = "Italy" });

			return countries;
		}

		private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			//Please replace the following line with your own selection changed handling code 
			Debug.WriteLine("ComboBox selection changed!");
		}
	}

	public class Country
	{
		public int ID { get; set; }
		public string Name { get; set; }
	}
	public class Person
	{
		public Person(int countryID, string firstName, string lastName)
		{
			this.CountryID = countryID;
			this.FirstName = firstName;
			this.LastName = lastName;
		}

		public int CountryID { get; set; }
		public string FirstName { get; set; }
		public string LastName { get; set; }

		public static List<Person> GetSampleListOfPersons()
		{
			var persons = new List<Person>
			              	{
			              		new Person(1, "John", "Smith"),
			              		new Person(2, "Jane", "Smith"),
			              		new Person(3, "Peter", "Smith")
			              	};
			return persons;
		}
	}
}
