public void AddToBestelling(object sender, int id) { BestellingProduct bestellingProduct = new BestellingProduct(); bestellingProduct.ProductID = id; Button button = (Button)sender; WrapPanel wrapPanel = (WrapPanel)button.Parent; Xceed.Wpf.Toolkit.ShortUpDown textBox = (Xceed.Wpf.Toolkit.ShortUpDown)wrapPanel.Children[1]; bestellingProduct.Aantal = Convert.ToInt32(textBox.Text); newOrder.BestellingProduct.Add(bestellingProduct); ctx.Bestelling.Add(newOrder); MessageBox.Show($"Product {bestellingProduct.Product} aantal:{bestellingProduct.Aantal.ToString()}"); }
private void GenerateHostControl(object DefaultValue, Type CurrentType) { if (DefaultValue != null) { HostType = DefaultValue.GetType(); } else { HostType = CurrentType; } LastValue = DefaultValue; if (HostType == typeof(byte)) { ByteNumericControl = new Xceed.Wpf.Toolkit.ByteUpDown(); ByteNumericControl.UpdateValueOnEnterKey = true; ByteNumericControl.Value = (byte)DefaultValue; ValueControl.Value1Host.Children.Add(ByteNumericControl); } else if (HostType == typeof(ushort)) { UShortNumericControl = new Xceed.Wpf.Toolkit.UShortUpDown(); UShortNumericControl.UpdateValueOnEnterKey = true; UShortNumericControl.Value = (ushort)DefaultValue; ValueControl.Value1Host.Children.Add(UShortNumericControl); } else if (HostType == typeof(uint)) { UIntNumericControl = new Xceed.Wpf.Toolkit.UIntegerUpDown(); UIntNumericControl.UpdateValueOnEnterKey = true; UIntNumericControl.Value = (uint)DefaultValue; ValueControl.Value1Host.Children.Add(UIntNumericControl); } else if (HostType == typeof(sbyte)) { SByteNumericControl = new Xceed.Wpf.Toolkit.SByteUpDown(); SByteNumericControl.UpdateValueOnEnterKey = true; SByteNumericControl.Value = (sbyte)DefaultValue; ValueControl.Value1Host.Children.Add(SByteNumericControl); } else if (HostType == typeof(short)) { ShortNumericControl = new Xceed.Wpf.Toolkit.ShortUpDown(); ShortNumericControl.UpdateValueOnEnterKey = true; ShortNumericControl.Value = (short)DefaultValue; ValueControl.Value1Host.Children.Add(ShortNumericControl); } else if (HostType == typeof(int)) { IntNumericControl = new Xceed.Wpf.Toolkit.IntegerUpDown(); IntNumericControl.UpdateValueOnEnterKey = true; IntNumericControl.Value = (int)DefaultValue; ValueControl.Value1Host.Children.Add(IntNumericControl); } else if (HostType == typeof(bool)) { BoolCheckboxControl = new System.Windows.Controls.CheckBox(); BoolCheckboxControl.IsChecked = (bool)DefaultValue; BoolCheckboxControl.VerticalAlignment = System.Windows.VerticalAlignment.Center; BoolCheckboxControl.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; BoolCheckboxControl.VerticalContentAlignment = System.Windows.VerticalAlignment.Center; BoolCheckboxControl.HorizontalContentAlignment = System.Windows.HorizontalAlignment.Left; ValueControl.Value1Host.Children.Add(BoolCheckboxControl); } else if (HostType == typeof(string)) { StringTextboxControl = new System.Windows.Controls.TextBox() { IsInactiveSelectionHighlightEnabled = true }; StringTextboxControl.Text = (string)DefaultValue; TextBoxLastString = (string)DefaultValue; ValueControl.Value1Host.Children.Add(StringTextboxControl); } else if (HostType == typeof(float)) { FloatNumericControl = new Xceed.Wpf.Toolkit.SingleUpDown(); FloatNumericControl.UpdateValueOnEnterKey = true; FloatNumericControl.Value = (float)DefaultValue; ValueControl.Value1Host.Children.Add(FloatNumericControl); } else if (HostType == typeof(System.Drawing.Color)) { ColorPickerControl = new Xceed.Wpf.Toolkit.ColorPicker(); System.Drawing.Color initalColor = (System.Drawing.Color)DefaultValue; ColorPickerLastColor = new System.Windows.Media.Color() { A = initalColor.A, R = initalColor.R, G = initalColor.G, B = initalColor.B }; ColorPickerControl.SelectedColor = ColorPickerLastColor; ValueControl.Value1Host.Children.Add(ColorPickerControl); } EnableEvents(); }