using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace ViewModelTest_combo
{
	public partial class MainPage : UserControl
	{
		public MainPage()
		{
			InitializeComponent();
			this.TelerikGridView.DataContext = new MainPageViewModel();
		}
	}

	public class MainPageViewModel : INotifyPropertyChanged
	{

		private ObservableCollection<LISDummyData> m_DummyData = null;
		private ObservableCollection<LISComboItem> m_ComboItems = null;
		public MainPageViewModel()
		{
			ComboItemList = GetComboItems();
			DummyDataList = GetData();
		}

		private ObservableCollection<LISDummyData> GetData()
		{

			ObservableCollection<LISDummyData> data = new ObservableCollection<LISDummyData>();
			data.Add(new LISDummyData(){ Date = DateTime.Now, Flag = true, Name = "Name1", Number = 1 });
			data.Add(new LISDummyData(){ Date = DateTime.Now, Flag = true, Name = "Name2", Number = 2 });

			return data;
		}

		private ObservableCollection<LISComboItem> GetComboItems()
		{
			ObservableCollection<LISComboItem> comboItems = new ObservableCollection<LISComboItem>();
			comboItems.Add(new LISComboItem(){ DisplayValue = "One", Value = 1 });
			comboItems.Add(new LISComboItem() { DisplayValue = "Two", Value = 2 });

			return comboItems;
		}

		public ObservableCollection<LISDummyData> DummyDataList
		{
			get
			{
				return m_DummyData;
			}
			set
			{
				m_DummyData = value;

				OnPropertyChanged("DummyDataList");
			}
		}

		public ObservableCollection<LISComboItem> ComboItemList
		{
			get
			{
				return m_ComboItems;
			}

			set
			{
				m_ComboItems = value;

				OnPropertyChanged("ComboItemList");
			}
		}

		protected virtual void OnPropertyChanged(String PropertyName)
		{

			if (PropertyChanged != null)

				PropertyChanged(this, new PropertyChangedEventArgs(PropertyName));
		}

		#region INotifyPropertyChanged Members
		public event PropertyChangedEventHandler PropertyChanged;
		#endregion
	}

	public class LISComboItem 
	{
		public int Value
		{
			get;
			set;
		}

		public String DisplayValue
		{
			get;
			set;
		}
	}

	public class LISDummyData 
	{

		public String Name
		{

			get;
			set;
		}

		public bool Flag
		{
			get;
			set;
		}

		public DateTime Date
		{

			get;
			set;
		}

		public int Number
		{
			get;
			set;
		}
	} 
}
