
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
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 System.Windows.Threading;
using Telerik.Windows.Controls;

namespace LightweightTemplatesDemo
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        Stopwatch stopWatch = new Stopwatch();
        public MainWindow()
        {
            InitializeComponent();
        }
        void gridView_LayoutUpdated(object sender, EventArgs e)
        {
           this.gridView.LayoutUpdated -= gridView_LayoutUpdated;
            stopWatch.Stop();
            TimeSpan ts = stopWatch.Elapsed;
            textBlock.Text = String.Format("{0:00}:{1:00}:{2:00}.{3:00}",
            ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10);
        } 
        private void LoadGridView(RadGridView grid)
        {
            List<int> _list = new List<int>();
            for (int x = 0; x < 1000; x++)
            {
                grid.Columns.Add(new GridViewDataColumn() { Header = "Col" + x.ToString(), DataMemberBinding = new Binding() });
            }
            for (int x = 0; x < 100000; x++)
            {
                _list.Add(x);
            }
            grid.ItemsSource = _list;
        }
       private void measureButton_Click(object sender, RoutedEventArgs e)
       {
           this.gridView.LayoutUpdated += gridView_LayoutUpdated;
           stopWatch.Start();
           LoadGridView(gridView);
       }
    }
}