using System.Windows;
using Telerik.Windows.Controls;
using Telerik.Windows.Data;
using System.Data;
using System.Windows.Data;
using System.Windows.Controls;

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

		private void DataToGrid1()
		{
			DataTable myDataTable = new DataTable();
			myDataTable.Columns.Add("Id", typeof(int));
			myDataTable.Columns.Add("Model", typeof(string));
			myDataTable.Columns.Add("Color", typeof(string));
			myDataTable.Columns.Add("Prize", typeof(double));

			for (int i = 0; i < 6; i++)
			{
				myDataTable.Rows.Add(i, "BMW", "Blue", 5700);
			}
			myDataTable.AcceptChanges();

			radGridView1.ItemsSource = myDataTable;

		}

		private void radGridView1_LoadingRowDetails(object sender, Telerik.Windows.Controls.GridView.GridViewRowDetailsEventArgs e)
		{
			var target = e.DetailsElement.FindName("rowDetailsTextBlock") as TextBlock;
			if (target != null)
			{
				Binding textBinding = new Binding("Text") { Source=this.textBox1, };
				target.SetBinding(TextBlock.TextProperty, textBinding);
			}
		}  
	}
}
