using System.Collections.Generic;
using Microsoft.Phone.Controls;

using ControlExamples.Objects;
using System.Windows.Controls;
using System;
using System.Windows.Media.Imaging;
using System.Windows;

namespace Controls.Pages
{
    public partial class ListBoxPage : PhoneApplicationPage
    {
        public ListBoxPage()
        {
            InitializeComponent();

            //// einfache Listbox mit 5 Eintraegen erstellen
            //ListBox listBox1 = new ListBox();
            //listBox1.Height = 81;
            //listBox1.Width = 444;
            //listBox1.Margin = new System.Windows.Thickness(24, 29, 0, 0);
            //listBox1.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            //listBox1.VerticalAlignment = System.Windows.VerticalAlignment.Top;

            //for (int i = 0; i < 5; i++)
            //{
            //    ListBoxItem lbi = new ListBoxItem();
            //    lbi.Content = "Listeneintrag " + i;
            //    listBox1.Items.Add(lbi);
            //}

            //// Listbox mit 5 Eintreagen und Mehrfachauswahl erstellen
            //ListBox listBox2 = new ListBox();
            //listBox2.Height = 84;
            //listBox2.Width = 444;
            //listBox2.Margin = new System.Windows.Thickness(24, 135, 0, 0);
            //listBox2.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            //listBox2.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            //listBox2.SelectionMode = SelectionMode.Multiple;

            //for (int j = 0; j < 5; j++)
            //{
            //    ListBoxItem lbi = new ListBoxItem();
            //    lbi.Content = "Mehrfachauswahl Listeneintrag " + j;
            //    listBox2.Items.Add(lbi);
            //}

            //// Listbox mit Content Controls erstellen
            //ListBox listBox3 = new ListBox();
            //listBox3.Height = 165;
            //listBox3.Width = 444;
            //listBox3.Margin = new System.Windows.Thickness(24, 239, 0, 0);
            //listBox3.HorizontalAlignment = System.Windows.HorizontalAlignment.Left;
            //listBox3.VerticalAlignment = System.Windows.VerticalAlignment.Top;
            //listBox3.SelectionMode = SelectionMode.Extended;

            //for (int j = 0; j < 5; j++)
            //{
            //    CheckBox checkbox = new CheckBox();

            //    TextBlock textblock = new TextBlock();
            //    textblock.Text = "CheckBox mit TextBlock";
            //    Image image = new Image();
            //    image.Source = new BitmapImage(new Uri("/ApplicationIcon.png", UriKind.Relative));
            //    image.Height = 43;
            //    image.Width = 43;
            //    image.Margin = new System.Windows.Thickness(10, 0, 20, 0);
            //    StackPanel stackpanel = new StackPanel();
            //    stackpanel.Orientation = System.Windows.Controls.Orientation.Horizontal;
            //    stackpanel.Children.Add(textblock);
            //    stackpanel.Children.Add(image);

            //    checkbox.Content = stackpanel;

            //    ListBoxItem lbi = new ListBoxItem();
            //    lbi.Content = checkbox;
            //    listBox3.Items.Add(lbi);              
            //}

            //ContentGrid.Children.Add(listBox1);
            //ContentGrid.Children.Add(listBox2);
            //ContentGrid.Children.Add(listBox3);

            // Erzeugen von Demodaten
            List<Person> customers = new List<Person>()
            {
                new Person { ID = 1, FirstName = "Simon", LastName = "Hackfort", 
                    Orders=new List<Order>{new Order{ID=1, Info="1kg Kirschen"},new Order{ID=2, Info="500g Kiwis"}} },
                new Person { ID = 2, FirstName = "Peter", LastName = "Nowak",
                    Orders=new List<Order>{new Order{ID=3, Info="2kg Bananen"},new Order{ID=4, Info="4 Stück Melonen"}} },
                new Person { ID = 3, FirstName = "Patrick", LastName = "Getzmann",
                    Orders=new List<Order>{new Order{ID=5, Info="5t Getreide"},new Order{ID=6, Info="4 Pilze"},new Order{ID=7, Info="7 Kokosnüsse"}} }
            };

            // DataBinding mit dem Objekt customers an die 4. ListBox
            listBox4.ItemsSource = customers;
        }
    }
}