public async void HandleRowTapped(object sender, ItemTappedEventArgs e) { MashTableRowDataModel selected = e.Item as MashTableRowDataModel; var answer = await DisplayAlert(selected.SelectedGrain.GrainName, "Would you like to delete this grain?", "Yes", "No"); if (answer == true) { MessagingCenter.Send <MashCalculatorPageXAML, MashTableRowDataModel>(this, "DeleteGrainXAML", selected); } ; }
async void HandleItemTapped(object sender, ItemTappedEventArgs e) { MashTableRowDataModel selected = e.Item as MashTableRowDataModel; var answer = await DisplayAlert("Delete Hop", "Would you like to delete this hop?", "Yes", "No"); if (answer == true) { MessagingCenter.Send <MashCalculatorPage, MashTableRowDataModel>(this, "DeleteGrain", selected); } ; grainsAddedListView.SelectedItem = null; }
public MashListView() { //Create list of grains ObservableCollection <MashTableRowDataModel> grainsAdded = new ObservableCollection <MashTableRowDataModel> (); //Set properties and source for table // VerticalOptions = LayoutOptions.Start; HorizontalOptions = LayoutOptions.FillAndExpand; ItemsSource = grainsAdded; //Create ItemTemplate for rows ItemTemplate = new DataTemplate(() => { return(new ViewCell { View = new MashViewCell() }); }); MessagingCenter.Subscribe <MashCalcAddGrainPage, Grains> (this, "AddGrain", (sender, arg) => { MashTableRowDataModel added = new MashTableRowDataModel { SelectedGrain = arg as Grains, Pounds = "0" }; grainsAdded.Add(added); }); MessagingCenter.Subscribe <MashCalcAddGrainPageXAML, Grains> (this, "AddGrainXAML", (sender, arg) => { MashTableRowDataModel added = new MashTableRowDataModel { SelectedGrain = arg as Grains, Pounds = "0" }; grainsAdded.Add(added); }); MessagingCenter.Subscribe <MashCalculatorPage, MashTableRowDataModel> (this, "DeleteGrain", (sender, arg) => { grainsAdded.Remove(arg); }); MessagingCenter.Subscribe <MashCalculatorPageXAML, MashTableRowDataModel> (this, "DeleteGrainXAML", (sender, arg) => { grainsAdded.Remove(arg); }); MessagingCenter.Subscribe <MashCalculatedResultsPage> (this, "ClearTable", (sender) => { grainsAdded.Clear(); }); MessagingCenter.Subscribe <MashCalculatedResultsPageXAML> (this, "ClearTableXAML", (sender) => { grainsAdded.Clear(); }); }