async void Handle_ItemTapped(object sender, Xamarin.Forms.ItemTappedEventArgs e) { var eventsSource = (ObservableCollection <Session>)EventsListView.ItemsSource; var index = eventsSource.IndexOf((Session)EventsListView.SelectedItem); if (index == 0) { var onTop = await DisplayAlert("Top Element", "Add on top or below?", "Top", "Below"); if (onTop) { await EventListHelper.addNewEvent(_newSession); } else { await EventListHelper.addNewEvent(_newSession, index + 1); } } else { await EventListHelper.addNewEvent(_newSession, index + 1); } await DisplayAlert("Great!", "Event added!", "Ok"); CanGoBack = true; await Navigation.PopAsync(); }
public void addtoCalendar(BaseDataSource payload) { //build our object var startTime = (DateTime)payload["start"]; var endTime = (DateTime)payload["end"]; var desc = (string)payload["abstract"]; var location = (string)payload["room"]; var title = (string)payload["title"]; Debug.WriteLine(startTime); //add event to calendar Device.BeginInvokeOnMainThread(async() => { var answer = await DisplayAlert("Add Event to Calendar?", "Save this event for later", "Yes", "No"); if (answer) { var eventDetails = new CalendarEvent() { Start = startTime, End = endTime, Description = desc, Location = location, Name = title, ExternalID = "makerspace" }; if (Device.OS != TargetPlatform.Android) { await EventListHelper.incrementAttendeeCount(); } try { var localCalendar = await GetOrCreateMakerCalendarAsync(); await CrossCalendars.Current.AddOrUpdateEventAsync(localCalendar, eventDetails); await DisplayAlert("Done!", "Added to Calendar", "Yay!"); } catch (UnauthorizedAccessException) { await DisplayAlert("Uh-Oh", "Go to Settings and Enable Calendar Access for this App!", "Ok"); } } }); }
async void Handle_Clicked(object sender, System.EventArgs e) { var confirm = await DisplayAlert("Sure?", "Delete this event?", "Yes", "No"); if (confirm) { var button = (Button)sender; var selection = (DataItem)button.CommandParameter; var eventID = Int32.Parse(selection.Name); await EventListHelper.removeEvent(eventID); await DisplayAlert("Deleted!", "Cool, bye bye event", "Done"); CanGoBack = true; await Navigation.PopAsync(); } }