using GalaSoft.MvvmLight;
using System.Collections.ObjectModel;
using GestionArticle.Model;
using GalaSoft.MvvmLight.Command;
using System.Windows.Input;
namespace GestionArticle.ViewModel
{
    /// <summary>
    /// This class contains properties that a View can data bind to.
    /// <para>
    /// See http://www.galasoft.ch/mvvm
    /// </para>
    /// </summary>
    public class MainViewModel : ViewModelBase, IMainViewModel
    {
        /// <summary>
        /// Initializes a new instance of the MainViewModel class.
        /// </summary>

        private readonly ObservableCollection<Article> article;
        public MainViewModel()
        {
            
            article = new ObservableCollection<Article>();
            article.Add(new Article { Nom = "article 1" });
            ChargerArticleCommand = new RelayCommand(ChargerArticles);
        }

        private void ChargerArticles()
        {
            this.article.Add(new Article { Nom = "Article 2" });
        }

        private string _titre;
        public string Titre
        {
            get { return _titre; }
            set
            {
                _titre = value;
                RaisePropertyChanged("Titre");
            }
        }

        public ObservableCollection<Article> Articles
        {
            get { return this.article; }
        }

        public ICommand ChargerArticleCommand
        {
            get;
            private set;
        }
    }
}