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 System.Collections.ObjectModel;

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

        private void exampleData_Loaded(object sender, RoutedEventArgs e)
        {
            exampleData.ItemsSource = GetData();
        }

        private ObservableCollection<Customer> GetData()
        {
            ObservableCollection<Customer> result = new ObservableCollection<Customer>();
            for (int i = 0; i < 10; i++)
            {
                Customer c = new Customer();
                c.CustomerName = "Larry "+i;
                c.Id = i;
                c.Orders = new List<Order>()
                {
                    new Order()
                    {
                        EndDate=DateTime.Now,
                        OrderDescription="Buyed Milk. Order #:"+i,
                        StartDate=DateTime.Now
                    },
                                        new Order()
                    {
                        EndDate=DateTime.Now,
                        OrderDescription="Buyed Terry Pratchet book. Order #:"+i,
                        StartDate=DateTime.Now
                    },
                                        new Order()
                    {
                        EndDate=DateTime.Now,
                        OrderDescription="Bread. Order #:"+i,
                        StartDate=DateTime.Now
                    },
                                        new Order()
                    {
                        EndDate=DateTime.Now,
                        OrderDescription="Beer. Order #:"+i,
                        StartDate=DateTime.Now
                    },
                };
                result.Add(c);
            }

            return result;

        }
    }

    public class Customer
    {
        public string CustomerName { get; set; }
        public int Id { get; set; }
        public List<Order> Orders { get; set; }
    }

    public class Order
    {
        public string OrderDescription { get; set; }
        public DateTime StartDate { get; set; }
        public DateTime EndDate { get; set; }
    }
}
