using System;
using System.Windows;
using Telerik.Windows.Controls;
using Telerik.Windows.Controls.GridView;

namespace LoadRowDetails
{
	/// <summary>
	/// Interaction logic for MainWindow.xaml
	/// </summary>
	public partial class MainWindow : Window
	{
		public MainWindow()
		{
			InitializeComponent();
			this.Loaded += new RoutedEventHandler(MainWindow_Loaded);

			this.clubsGrid.AddHandler(GridViewRow.IsExpandedChangedEvent, new RoutedEventHandler(OnIsExpandedChanged), true);
		}

		private void OnIsExpandedChanged(object sender, RoutedEventArgs e)
		{
			
		}

		void MainWindow_Loaded(object sender, RoutedEventArgs e)
		{
			
		}
		
		private void playersGrid_Loaded(object sender, RoutedEventArgs e)
		{
			var childGrid = (RadGridView)sender;
			var parentRow = childGrid.ParentRow;

			if (parentRow != null)
			{
				this.clubsGrid.SelectedItem = childGrid.DataContext;
			//	parentRow.IsExpandedChanged += new RoutedEventHandler(parentRow_IsExpandedChanged);
			}
		}

		void parentRow_IsExpandedChanged(object sender, RoutedEventArgs e)
		{
			this.clubsGrid.SelectedItem = ((GridViewRow)sender).DataContext;
		//	this.clubsGrid.ExpandAllHierarchyItems();
		}
	}
}
