using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;

namespace SilverlightApplication106
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
            testGrid.ItemsSource = TestItem.Generate(100);
            testGrid.CellEditEnded += new EventHandler<GridViewCellEditEndedEventArgs>(testGrid_CellEditEnded);
        }

        void testGrid_CellEditEnded(object sender, GridViewCellEditEndedEventArgs e)
        {
            //Here you can submit the changes
        }     


        private void CheckBox_Click(object sender, RoutedEventArgs e)
        {
            if ((sender as CheckBox).ParentOfType<GridViewCell>().IsInEditMode)
                (sender as CheckBox).ParentOfType<GridViewCell>().CommitEdit();
        }   
    }

    public class TestItem
    {
        private static Random rnd = new Random();
        public int Prop1 { get; set; }
        public bool Prop2 { get; set; }

        public TestItem()
        {
            Prop1 = rnd.Next(100);
            Prop2 = (rnd.Next(2) == 0) ? false : true;
        }

        public static ObservableCollection<TestItem> Generate(int count)
        {
            ObservableCollection<TestItem> res = new ObservableCollection<TestItem>();
            for (int i = 0; i < count; i++)
            {
                res.Add(new TestItem());
            }

            return res;
        }
    }
}
