private void removeFromControl(string Name) { PillControl pc = (PillControl)hold.FindName(Name); if (pc != null) { hold.UnregisterName(pc.Name); hold.Children.Remove(pc); } }
private void Button_Click(object sender, RoutedEventArgs e) { PillControl pc = new PillControl(); pc.Name = $"pc{kp}"; pc.textValue = txtQ.Text; pc.xCloseClick = removeFromControl; pc.Margin = new Thickness(3, 0, 0, 0); hold.RegisterName(pc.Name, pc); hold.Children.Add(pc); kp++; }