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

namespace WPBinding3
{
    public partial class MainPage : PhoneApplicationPage
    {
        ObservableCollection<Person> persons = new ObservableCollection<Person>();

        // Constructor
        public MainPage()
        {
            InitializeComponent();
            Person p = new Person();
            p.FirstName = "Max";
            p.Name = "Mustermann";
            p.Age = 21;
            persons.Add(p);

            p = new Person();
            p.FirstName = "Susanne";
            p.Name = "Mustermann";
            p.Age = 19;
            persons.Add(p);

            lbPersons.ItemsSource = persons;
        }

        private void btnAddPerson_Click(object sender, System.Windows.RoutedEventArgs e)
        {
            Person p = new Person();
            p.FirstName = "Julian";
            p.Name = "Mustermann";
            p.Age = 22;
            persons.Add(p);
        }
    }
}