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 System.ComponentModel;
using System.Collections.ObjectModel;
using Telerik.Windows.Controls.DragDrop;

namespace WindowsFormsApplication5
{
    /// <summary>
    /// Interaction logic for UserControl1.xaml
    /// </summary>
    public partial class UserControl1 : UserControl
    {
        public UserControl1()
        {
            RadDragAndDropManager.EnableNativeDrag = true;

            InitializeComponent();

            this.DataContext = new MainViewModel();
        }
    }

        
    public class User : INotifyPropertyChanged
    {
        private int id;

        public int Id
        {
            get
            {
                return id;
            }
            set
            {
                id = value;
                this.OnPropertyChanged("Id");
            }
        }

        private string userName;

        public string UserName
        {
            get
            {
                return userName;
            }
            set
            {
                userName = value;
                this.OnPropertyChanged("UserName");
            }
        }

        private DateTime lastLoginDate;

        public DateTime LastLoginDate
        {
            get
            {
                return lastLoginDate;
            }
            set
            {
                lastLoginDate = value;
                this.OnPropertyChanged("LastLoginDate");
            }
        }


        private bool active;

        public bool Active
        {
            get
            {
                return active;
            }
            set
            {
                active = value;
                this.OnPropertyChanged("Active");
            }
        }


        private bool approved;

        public bool Approved
        {
            get
            {
                return approved;
            }
            set
            {
                approved = value;
                this.OnPropertyChanged("Approved");
            }
        }


        public event PropertyChangedEventHandler PropertyChanged;

        protected virtual void OnPropertyChanged(string propertyName)
        {
            if (this.PropertyChanged != null)
            {
                this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
            }
        }
    }

    public class MainViewModel
    {
        private ObservableCollection<User> data;

        public ObservableCollection<User> Data
        {
            get { return data; }
            set { data = value; }
        }

        public MainViewModel()
        {
            GenerateData(10);
        }

        private void GenerateData(int c)
        {
            this.data = new ObservableCollection<User>((
                from p in Enumerable.Range(0, c)
                select new User
                {
                    Id = p,
                    Active = p % 2 == 0,
                    Approved = p % 3 == 0,
                    LastLoginDate = DateTime.Now.AddDays(-p),
                    UserName = "User " + p
                }).ToList());
        }

    }
      
}
