private async void Delete(object sender, EventArgs e) { Button button = (Button)sender; int notification_to_delete = (int)button.CommandParameter; HttpResponseMessage response = await NotificationRequest.DeleteNotification(notification_to_delete); if (response.IsSuccessStatusCode) { try { OutputNotification obs_to_remove = Notifications.Find(OutputNotification => OutputNotification.Notification.Id == notification_to_delete); Notifications.Remove(obs_to_remove); MyCollectionView.ItemsSource = null; MyCollectionView.ItemsSource = Notifications; await DisplayAlert("Success!", "Notification removed", "OK"); } catch (Exception ex) { await DisplayAlert("Error!", "Something went wrong", "OK"); } } else { if (response.StatusCode == System.Net.HttpStatusCode.BadGateway) { await DisplayAlert("Attention!!!", "No connection with the server", "OK"); } if (response.StatusCode == System.Net.HttpStatusCode.BadRequest) { await DisplayAlert("Try Again!", "Invalid request", "OK"); } } }