private void IngredientsListView_ItemClick(object sender, ItemClickEventArgs e) { _productIngredientUnderEdit = e.ClickedItem as ProductIngredient; if (_productIngredientUnderEdit == null) { return; } _isProductIngredientUnderEdit = true; ShowIngredientsCommandBar(); ingredientComboBox.SelectedValue = _productIngredientUnderEdit.Ingredient; ingredientCountTextBox.Text = _productIngredientUnderEdit.IngredientCount.ToString(); }
private void ingredientEditButton_Click(object sender, RoutedEventArgs e) { decimal ingredientCount = 0.0M; if (!decimal.TryParse(ingredientCountTextBox.Text, out ingredientCount)) { ingredientCountTextBox.Focus(FocusState.Programmatic); return; } _product.Ingredients.Remove(_productIngredientUnderEdit); _product.Ingredients.Add(new ProductIngredient(_productIngredientUnderEdit.Ingredient, ingredientCount)); _productIngredientUnderEdit = null; _isProductIngredientUnderEdit = false; ShowIngredientsCommandBar(); ClearIngredientControls(); }