private async void Delete_Tapped(object sender, EventArgs e) { MainListItem selectedItem = allListsSource.First <MainListItem>(x => x.ID == (int)((TappedEventArgs)e).Parameter); if (selectedItem != null && selectedItem.ID > 0 && await DisplayAlert("Delete", "Are you sure you want to delete " + selectedItem.DisplayName, "OK", "CANCEL")) { allListsSource.Remove(selectedItem); Application.Current.Properties[App.Current.Resources["AllListsSource"].ToString()] = JsonConvert.SerializeObject(allListsSource); await Application.Current.SavePropertiesAsync(); } }
public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { MainListItem mainListItem = (MainListItem)holder; mainListItem.mealTV.Text = shoppingList[position]; mainListItem.infoButton.Click += (object o, EventArgs a) => { View v = (View)o; Toast.MakeText(v.Context, "INFO CLICKED", ToastLength.Short).Show(); }; mainListItem.editButton.Click += (object o, EventArgs a) => { View v = (View)o; Toast.MakeText(v.Context, "EDIT CLICKED", ToastLength.Short).Show(); }; }
private async void OnOkTap(object sender, EventArgs e) { if (txtNewName.Text != null && txtNewName.Text.Trim().Length > 0) { if (indexProductList == -1) { listToEdit[indexMainList] = new MainListItem(listToEdit[indexMainList].ID, txtNewName.Text, listToEdit[indexMainList].ProductsList); } else { listToEdit[indexMainList].ProductsList[indexProductList] = new ProductListItem(listToEdit[indexMainList].ProductsList[indexProductList].ID, txtNewName.Text, listToEdit[indexMainList].ProductsList[indexProductList].Type, listToEdit[indexMainList].ProductsList[indexProductList].Image); } Application.Current.Properties[App.Current.Resources["AllListsSource"].ToString()] = JsonConvert.SerializeObject(listToEdit); await Application.Current.SavePropertiesAsync(); await PopupNavigation.Instance.PopAsync(); } }