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

namespace RadGridView_WPF_AR_69
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();
            FrameworkElementFactory detailsTemplate = new FrameworkElementFactory(typeof(RadGridView));
            detailsTemplate.SetBinding(RadGridView.ItemsSourceProperty, new Binding("Players"));
            detailsTemplate.SetValue(RadGridView.AutoGenerateColumnsProperty, false);
            DataTemplate dt = new DataTemplate();
            dt.VisualTree = detailsTemplate;
            dt.Seal();
            clubsGrid.RowDetailsTemplate = dt;
            clubsGrid.LoadingRowDetails += new EventHandler<GridViewRowDetailsEventArgs>(clubsGrid_LoadingRowDetails);
        }

        void clubsGrid_LoadingRowDetails(object sender, GridViewRowDetailsEventArgs e)
        {
            (e.DetailsElement as RadGridView).Columns.Add(new GridViewDataColumn() { DataMemberBinding = new Binding("Name") });
            (e.DetailsElement as RadGridView).Columns.Add(new GridViewDataColumn() { DataMemberBinding = new Binding("Position") });
        } 
    }
}
