Exemplo n.º 1
0
        public AttendeeList()
        {
            list = new ListView ();
            list.ItemTemplate = new DataTemplate(typeof(TextCell));
            list.ItemTemplate.SetBinding (TextCell.TextProperty, "name");
            list.ItemTemplate.SetBinding (TextCell.DetailProperty, "email");

            list.ItemSelected += (object sender, SelectedItemChangedEventArgs e) => {
                var attendee = (Attendee) e.SelectedItem;
                var AttendeePage = new AttendeePage();
                AttendeePage.BindingContext = attendee;
                Navigation.PushAsync(AttendeePage);
            };

            Button addButton = new Button {
                HorizontalOptions = LayoutOptions.CenterAndExpand,
                Text = "Add Attendee"
            };

            addButton.Clicked += (object sender, EventArgs e) => {
                var attendee = new Attendee();
                var AttendeePage = new AttendeePage();
                AttendeePage.BindingContext = attendee;
                Navigation.PushAsync(AttendeePage);
            };

            list.ItemsSource = App.Database.GetItems ();
            this.Padding = new Thickness (0, Device.OnPlatform (20, 0, 0), 0, 0);

            StackLayout stack = new StackLayout {
                Children = {list, addButton}
            };

            Content = stack;
        }
Exemplo n.º 2
0
 public int SaveItem(Attendee item)
 {
     lock (locker) {
         if (item.ID != 0) {
             database.Update(item);
             return item.ID;
         } else {
             return database.Insert(item);
         }
     }
 }