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 Telerik.Windows.Controls.GridView;

namespace MultiColumnCombo_WPF
{
	/// <summary>
	/// Interaction logic for Window1.xaml
	/// </summary>
	public partial class Window1 : Window
	{
		public Window1()
		{
			InitializeComponent();
			this.Items = GetItems();

			this.RadGridView1.ItemsSource = this.Items;
		}

		private List<Item> Items;

		private List<Item> GetItems()
		{
			List<Item> items = new List<Item>();

			items.Add(new Item() { ID = 1, Count = 10, Description = "test 1" });
			items.Add(new Item() { ID = 2, Count = 11, Description = "test 2" });
			items.Add(new Item() { ID = 3, Count = 12, Description = "test 3" });
			
			return items;
		}

		private void RadComboBox_Loaded(object sender, RoutedEventArgs e)
		{
			RadComboBox combo = sender as RadComboBox;
			combo.ItemsSource = this.Items;
			combo.SelectedItem = combo.DataContext;
		}

		private void RadComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
		{
			var item = new Item() { ID = 3, Count = 12, Description = "test 3" };
			GridViewRow parentRow =  ((RadComboBox)sender).ParentOfType<GridViewRow>();
			parentRow.Item = ((RadComboBox)sender).SelectedItem;
		}
	}

	public class Item
	{
		public int ID { get; set; }
		public string Description { get; set; }
		public int Count { get; set; }
	}
}
