using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Telerik.Windows.Controls;
using System.Collections.ObjectModel;
using System.Windows.Data;
using System.ComponentModel;

namespace RadGridView_TwoGridsToOneView
{
    public class MainViewModel : ViewModelBase
    {
        public MainViewModel()
        {
            this.Items = new ObservableCollection<Toto>();
            this.Items.Add(new Toto { Name = "AAAA", Num = 0 });
            this.Items.Add(new Toto { Name = "BBBB", Num = 1 });
            this.Items.Add(new Toto { Name = "CCCC", Num = 1 });
            this.Items.Add(new Toto { Name = "DDDD", Num = 0 });
            this.Items.Add(new Toto { Name = "EEEE", Num = 1 });
            this.Items.Add(new Toto { Name = "FFFF", Num = 0 });

            this.ItemsList = new ListCollectionView(this.Items);
        }

        private ObservableCollection<Toto> Items { get; set; }
        public ListCollectionView ItemsList { get; private set; }
    }

    public class Toto : ViewModelBase
    {
        public event PropertyChangedEventHandler PropertyChanged;
        private string name;
        public string Name
        {
            get { return name; }
            set { name = value; this.OnPropertyChanged("Name"); }
        }

        private bool isSelected;
        public bool IsSelected
        {
            get { return isSelected; }
            set { isSelected = value; this.OnPropertyChanged("IsSelected"); }
        }

        private int num;

        public int Num
        {
            get { return num; }
            set { num = value; }
        }

        protected virtual void OnPropertyChanged(PropertyChangedEventArgs args)
        {
            PropertyChangedEventHandler handler = this.PropertyChanged;
            if (handler != null)
            {
                handler(this, args);
            }
        }

        private void OnPropertyChanged(string propertyName)
        {
            this.OnPropertyChanged(new PropertyChangedEventArgs(propertyName));
        }
    }
}
