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

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

            DataTable table = new DataTable();
            table.Columns.Add(new DataColumn("ID", typeof(int)));
            table.Columns.Add(new DataColumn("Name", typeof(string)));

            for (var i = 0; i < 10; i++)
            {
                table.Rows.Add(new object[]{ i, String.Format("Name{0}", i)});
            }

            table.AcceptChanges();

            RadGridView1.ItemsSource = table;

            RadGridView1.RowLoaded += new EventHandler<RowLoadedEventArgs>(RadGridView1_RowLoaded);
        }

        void RadGridView1_RowLoaded(object sender, RowLoadedEventArgs e)
        {
            DataRow dataRow = e.Row.DataContext as DataRow;
            if (dataRow != null)
            {
                if (dataRow.RowState == DataRowState.Unchanged)
                {
                    e.Row.Background = Brushes.Green;
                }
                else if (dataRow.RowState == DataRowState.Modified)
                {
                    e.Row.Background = Brushes.Red;
                }
            }
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            ((DataTable) RadGridView1.ItemsSource).Rows[0].SetModified();
            RadGridView1.Rebind();
        }
    }
}
