//Opens a new window when a search item is clicked. public async void ItemTapped(object sender, ItemTappedEventArgs e) { if (e.Item == null) { return; //ItemSelected is called on deselection, which results in SelectedItem being set to null } //navigate to NutrFacts page, passing in the event arguments nutrFacts = new NutrFacts(this, (NumoNameSearch)e.Item); await Navigation.PushAsync(nutrFacts); selectedResult = (NumoNameSearch)e.Item; }
public NutrFacts(AddFoodPage aip, NumoNameSearch search) { InitializeComponent(); //save reference to food item selectedResult = search; //so the saveButtonClicked method can be used by the classes inheritting from AddItemPage this.aip = aip; //establish the save button on the top right ToolbarItem save = new ToolbarItem(); save.Text = "Save"; save.Clicked += saveButtonClicked; ToolbarItems.Add(save); //establish description view descrView.Text = search.ToString(); descrView.FontSize = Device.GetNamedSize(NamedSize.Large, typeof(Label)); descrView.VerticalOptions = LayoutOptions.Start; descrView.HorizontalOptions = LayoutOptions.Start; //set default units in picker //add any custom picker units from selected item updateUnitPickerWithCustomOptions(); //set default input values Quantity = "1"; UnitsPicker.SelectedIndex = 0; UnitPickerText = UnitsPicker.SelectedItem.ToString(); //so that it is not called incorrectly //get nutrient info on food item displayNutrInfo(); }