using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Hierarchy_WCFService.ServiceReference1;
using Telerik.Windows.Data;
using System.ComponentModel;
using System.Collections.ObjectModel;

namespace Hierarchy_WCFService
{
    public partial class SilverlightControl1 : UserControl
    {
        ObservableCollection<Customer> customers;
        ObservableCollection<Order> orders;

        public SilverlightControl1()
        {
            InitializeComponent();

            Service1Client client = new Service1Client();
            client.CustomerListCompleted += new EventHandler<CustomerListCompletedEventArgs>(client_CustomerListCompleted);
            client.CustomerListAsync();

            client.OrderListCompleted += new EventHandler<OrderListCompletedEventArgs>(client_OrderListCompleted);
            client.OrderListAsync();

            GroupDescriptor descriptor = new GroupDescriptor();
            descriptor.Member = "ShipCity";
            descriptor.SortDirection = ListSortDirection.Ascending;
            descriptor.DisplayContent = "ShipCity";
            customersGrid.GroupDescriptors.Add(descriptor);
        }

        void client_OrderListCompleted(object sender, OrderListCompletedEventArgs e)
        {
            this.customersGrid.ItemsSource = e.Result;
        }

        private void client_CustomerListCompleted(object sender, CustomerListCompletedEventArgs e)
        {

        }
    }
}
