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

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

		private void Button1_Click(object sender, RoutedEventArgs e)
		{
			var selectedRow = (GridViewRow)this.clubsGrid.ItemContainerGenerator.ContainerFromItem(this.clubsGrid.SelectedItem);
			var childGrid = selectedRow.ChildrenOfType<GridViewDataControl>().FirstOrDefault();
			if (childGrid != null)
			{
				Player currentPlayer = childGrid.CurrentItem as Player;
				MessageBox.Show("The name of the current player is: " + currentPlayer.Name);
			}
		}
	
	}
}
