private void addImage_Tapped(object sender, TappedRoutedEventArgs e) { numIngredients++; TextBox newTxtBox = new TextBox(); newTxtBox.Name = "Ingredient" + numIngredients; newTxtBox.Margin = new Thickness(10, 0, 0, 0); if (!flagColumn) { newTxtBox.SetValue(Grid.RowProperty, addImage.GetValue(Grid.RowProperty)); newTxtBox.SetValue(Grid.ColumnProperty, 0); IngredientsGrid.RowDefinitions.Add(new RowDefinition()); addImage.SetValue(Grid.RowProperty, ((int)addImage.GetValue(Grid.RowProperty) + 1)); } else { newTxtBox.SetValue(Grid.RowProperty, lastRow); newTxtBox.SetValue(Grid.ColumnProperty, 1); lastRow++; } IngredientsGrid.Children.Remove(addImage); IngredientsGrid.UpdateLayout(); IngredientsGrid.Children.Add(newTxtBox); IngredientsGrid.UpdateLayout(); IngredientsGrid.Children.Add(addImage); IngredientsGrid.UpdateLayout(); IngredientsPanel.UpdateLayout(); numberTxtBox++; if (numberTxtBox % 4 == 0) { flagColumn = !flagColumn; } // IngredientsPanel.Children.Add(addImage); }
private void addImage_Tapped(object sender, TappedRoutedEventArgs e) { numIngredients++; TextBox newTxtBox = new TextBox(); newTxtBox.Name = "AIngredient" + numIngredients; newTxtBox.Margin = new Thickness(10, 0, 0, 0); newTxtBox.SetValue(Grid.RowProperty, addImage.GetValue(Grid.RowProperty)); newTxtBox.SetValue(Grid.ColumnProperty, 0); IngredientsGrid.RowDefinitions.Add(new RowDefinition()); addImage.SetValue(Grid.RowProperty, ((int)addImage.GetValue(Grid.RowProperty) + 1)); IngredientsGrid.Children.Remove(addImage); IngredientsGrid.UpdateLayout(); IngredientsGrid.Children.Add(newTxtBox); IngredientsGrid.UpdateLayout(); IngredientsGrid.Children.Add(addImage); IngredientsGrid.UpdateLayout(); IngredientsPanel.UpdateLayout(); }