public ListItemComponent(XmlNode xmlNode, XmlSchemaElement xsdNode, StackPanel contentpanel, Panel overlaypanel, List<ListItemComponent> liolist, DynamicForm parentForm) { _optionlist = new List<AbstractDocUIComponent>(); _itempanel = new StackPanel() { Orientation = Orientation.Horizontal }; this._liolist = liolist; this._listpanel = contentpanel; this._node = xmlNode; Utilities.recursive(xsdNode, xmlNode, contentpanel, overlaypanel, (comp) => { comp.placeOption(); _optionlist.Add(comp); }, parentForm); Button delete = new Button(); delete.Content = "Remove item"; delete.Click += RemoveItem; delete.Click += (s, e) => { parentForm.PendingChanges = true; }; _itempanel.Children.Add(delete); contentpanel.Children.Add(_itempanel); }
/// <summary> /// Creates a new instance of an ExtendedTextbox. /// </summary> /// <param name="iconPath">path to the icon that should be displayed.</param> /// <param name="watermarkText">The watermark text.</param> /// <param name="regexCondition">The regularexpresion that should be validated.</param> /// <param name="required">Whether this textbox needs a content.</param> /// <param name="parentForm">The form in which this textbox is located.</param> public ExtendedTextBox(string iconPath, string watermarkText, string regexCondition, bool required, DynamicForm parentForm) { InitializeComponent(); this._parentForm = parentForm; this._required = required; this._watermarkText = watermarkText; // Initiate most of the content áfter everything is loaded. // This is necessary to know the textboxes width and height. this.Loaded += (object sender, RoutedEventArgs args) => { int image_width = 0; if (File.Exists(iconPath)) { BitmapImage bmp = new BitmapImage(new Uri(iconPath)); image_width = (int)((this.ActualHeight * bmp.PixelWidth) / bmp.PixelHeight); ImageDrawing i = new ImageDrawing(bmp, new Rect(new Size(image_width, this.ActualHeight))); img.Source = new DrawingImage(i); } watermark.Text = watermarkText; watermark.Foreground = new SolidColorBrush(Color.FromArgb(128, 0, 0, 0)); _regeExpr = new Regex(regexCondition); TextBlock.LostFocus += CheckWatermark; TextBlock.LostFocus += CheckRegex; TextBlock.TextChanged += CheckWatermark; TextBlock.TextChanged += CheckRegex; TextBlock.GotFocus += RemoveWatermark; TextBlock.GotFocus += CheckRegex; CheckWatermark(this, EventArgs.Empty); }; }