コード例 #1
0
        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);
            }
            ;
        }
コード例 #2
0
        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;
        }
コード例 #3
0
        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();
            });
        }