using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;

namespace WpfApplication4
{
    public class Stuff
    {
        public int ID { get; set; }
        public string Name { get; set; }
    }

    public class MainWindowViewModel : INotifyPropertyChanged
    {
        private PropertyChangedEventHandler _propertyChangedEvent;
        public event PropertyChangedEventHandler PropertyChanged
        {
            add
            {
                _propertyChangedEvent += value;
            }
            remove
            {
                _propertyChangedEvent -= value;
            }
        }

        protected virtual void NotifyPropertyChanged(string name)
        {
            PropertyChangedEventHandler handler = _propertyChangedEvent;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(name));
            }
        }

        private List<Stuff> _items;
        public List<Stuff> Items
        {
            get { return _items; }
            set
            {
                _items = value;
                NotifyPropertyChanged("Items");
            }
        }

        public void Test1()
        {
            Items = new List<Stuff>();
            for (int i = 0; i < 100; i++)
            {
                Items.Add(new Stuff() { Name = "item" + i.ToString(), ID = i });
            }
        }

        public void Test2()
        {
            var items = new List<Stuff>();
            items.Add(new Stuff() { Name = "item1", ID = 1 });
            items.Add(new Stuff() { Name = "item2", ID = 2 });
            items.Add(new Stuff() { Name = "item3", ID = 3 });

            Items = items;
        }
    }
}
