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

namespace RadGridView_WPF_AR_15
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        BackgroundWorker bw = new BackgroundWorker();
        MyViewModel vm = new MyViewModel();

        public MainWindow()
        {
            bw.WorkerReportsProgress = true;
            InitializeComponent();
            Binding bnd = new Binding("Clubs");
            bnd.Source = vm;
            clubsGrid.SetBinding(RadGridView.ItemsSourceProperty, bnd);          
            bw.DoWork += new DoWorkEventHandler(bw_DoWork);          
        }


        void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            vm.Clubs = Club.GetClubs();
        }

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            bw.RunWorkerAsync();
        }

        private void Button2_Click(object sender, RoutedEventArgs e)
        {
            vm.Clubs = Club.GetClubs();
        }
    }
}
