/// <summary> /// Searches using the given search terms and outputs to the page all the results that match that criteria. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private async void FindButtonClick(object sender, RoutedEventArgs e) { StaticData.masterPage.ShowProgressRing(); string searchTerms = SearchTermsTextBox.Text; if (searchTerms == searchTermsCache) { return; } if (string.IsNullOrEmpty(searchTerms)) { // Clear the results this.PageContentStackPanel.Children.Clear(); } else { this.PageContentStackPanel.Children.Clear(); // Perform a search foreach (var product in await Middleware.MiddlewareConnections.SearchForProduct(searchTerms)) { await Dispatcher.RunAsync(Windows.UI.Core.CoreDispatcherPriority.Normal, () => { var visualProduct = new ProductUserControl(); visualProduct.SetData(product); visualProduct.Tapped += VisualProductOnTapped; visualProduct.Margin = new Thickness(10, 10, 10, 50); PageContentStackPanel.Children.Add(visualProduct); }); } } searchTermsCache = searchTerms; StaticData.masterPage.HideProgressRing(); }
/// <summary> /// Externally load a product into this page and display on the screen /// </summary> /// <param name="product"></param> public void SetData(Product product) { this.product = product; var userControl = new ProductUserControl(); userControl.SetData(product); ProductGrid.Children.Add(userControl); NewQuantityTextBox.Text = product.stockCount.ToString(); }