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

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

            this.RadGridView1.RowLoaded += new EventHandler<Telerik.Windows.Controls.GridView.RowLoadedEventArgs>(RadGridView1_RowLoaded);
            RadGridView1.ItemsSource = new Message[] { 
				new Message { Sender = "tom@hanna-barbera.com", Subject = "Cats are cool", Size = 100 },
                new Message { Sender = "tom@hanna-barbera.com", Subject = "Cats are cool", Size = 2 },
                new Message { Sender = "tom@hanna-barbera.com", Subject = "Cats are cool", Size = 2 },
				new Message { Sender = "jerry@hanna-barbera.com", Subject = "Mice are cool", Size = 100 },
				new Message { Sender = "spike@hanna-barbera.com", Subject = "Dogs are cool", Size = 100 },
                new Message { Sender = "spike@hanna-barbera.com", Subject = "Dogs are cool2", Size = 50 }
			};
        }

        void RadGridView1_RowLoaded(object sender, RowLoadedEventArgs e)
        {
            if (e.Row is GridViewHeaderRow || e.Row is GridViewNewRow)
                return;

            GridViewRow row = (GridViewRow)e.Row;
            DataRecord rowRecord = (DataRecord)row.Record;
            Message dataItem = (Message)rowRecord.Data;

            if (dataItem.Size == 2)
                row.Background = Brushes.LightBlue;
        }
    }
}
