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.Collections.ObjectModel;

namespace Sample
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
        }

        private void Button1_Click(object sender, RoutedEventArgs e)
        {
            // here we know exactly what kind the backing items source is.
            var clubs = this.clubsGrid.ItemsSource as ObservableCollection<Club>;
            clubs.Add(new Club("MyClubName", DateTime.Today, 70000));
        }

        private void Button2_Click(object sender, RoutedEventArgs e)
        {
            // every AddNew call must be paired with a CommitNew call
            var club = this.clubsGrid.Items.AddNew() as Club;
            club.Name = "MyClubName";
            club.Established = DateTime.Today;
            club.StadiumCapacity = 70000;
            this.clubsGrid.Items.CommitNew();
        }
    }
}
