// Generates the input fields, depending to the selected category private void GenerateInputFields(StoreObject obj) { PropertyContents.Clear(); this.window.AddTabChildStack.Children.RemoveRange(1, this.window.AddTabChildStack.Children.Count - 1); var list = obj.GetType().GetProperties(); this.window.AddButton.IsEnabled = true; foreach (var item in list) { this.window.AddTabChildStack.Children.Add(new Label { Content = item.Name + ":" }); if (item.PropertyType.Name == "Branch") { TextBox box = new TextBox { Text = this.window.productCategories.SelectedItem.ToString(), Width = 150, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(10, 0, 0, 3) }; this.window.AddTabChildStack.Children.Add(box); PropertyContents.Add(box); } else if (item.PropertyType.Name == "Color") { var colors = new List<string>(); foreach (var color in Enum.GetValues(typeof(WarehouseSystem.Enumerations.Color))) { colors.Add(color.ToString()); } ComboBox comboBox = new ComboBox { ItemsSource = colors, Width = 150, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(10, 0, 0, 3) }; this.window.AddTabChildStack.Children.Add(comboBox); PropertyContents.Add(comboBox); } else if (item.PropertyType.Name == "Material") { var materials = new List<string>(); foreach (var material in Enum.GetValues(typeof(Material))) { materials.Add(material.ToString()); } ComboBox comboBox = new ComboBox { ItemsSource = materials, Width = 150, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(10, 0, 0, 3) }; this.window.AddTabChildStack.Children.Add(comboBox); PropertyContents.Add(comboBox); } else { TextBox box = new TextBox { MaxLength = 20, Width = 150, HorizontalAlignment = HorizontalAlignment.Left, Margin = new Thickness(10, 0, 0, 3) }; this.window.AddTabChildStack.Children.Add(box); PropertyContents.Add(box); } } }
public void AddProduct(StoreObject product) { this.productsList.Add(product); }