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

namespace _44630_Applying_Colors_Through_Binding
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			this.InitializeComponent();
			
			// Insert code required on object creation below this point.

			gridView.RowLoaded += new EventHandler<Telerik.Windows.Controls.GridView.RowLoadedEventArgs>(gridView_RowLoaded);
		}

		void gridView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
		{
			var row = e.Row as GridViewRow;
			if (row != null)
			{
				var cell = row.Cells.Where(c => c.Column.UniqueName == "Property5").FirstOrDefault();
				if (cell != null)
				{
					var value = cell.Content;
					e.Row.Background = new SolidColorBrush((Color)ColorConverter.ConvertFromString(value.ToString()));
				}
			}
		}
	}
}