private void Filter_Click(object sender, EventArgs e) { StackPanel s = new StackPanel(); var Min = new PhoneTextBox(); var Max = new PhoneTextBox(); Min.Hint = "Minimum Price"; Max.Hint = "Maximum Price"; s.Children.Add(Min); s.Children.Add(Max); CustomMessageBox messageBox = new CustomMessageBox() { Caption = "Filter by", Message = "Select the minimum and maximum prices, leave in blank to disable limit", LeftButtonContent = "Submit", Content = s, RightButtonContent = "Cancel" }; messageBox.Show(); messageBox.Dismissed += async(s1, e1) => { switch (e1.Result) { case CustomMessageBoxResult.LeftButton: var Count = 0; foreach (PivotItem pivot in CategoryPivot.Items) { var Listbox = Helper.FindFirstElementInVisualTree <ListBox>(pivot); Listbox.Items.Clear(); if (Listbox.ItemTemplate.Equals(Application.Current.Resources["ProductCategoryTemplate"] as DataTemplate)) { var Prods = await api.CategoryProductsSortedFiltered(Categories[Count].Id, false, true, ProductSortingEnum.Position, Decimal.Parse(Max.Text), Decimal.Parse(Min.Text)); foreach (ProductDTO p in Prods) { Listbox.Items.Add(new MainPage.ProductData { Id = p.Id, Description = p.Description, Image = Helper.ConvertToBitmapImage(p.Image.First()), ProductName = p.Name, Value = p.Price.ToString("0.0#") + " " + Currency }); } } Count++; } break; } }; }