private void UpdateAllControls() { VPanel_Repeaters.Children.Clear(); int k = 0; foreach (RepeatingData rdata in data.RepeatingControls) { RepeatingInfoControl repeatingInfoControl = new RepeatingInfoControl(); repeatingInfoControl.Margin = new Thickness(10); repeatingInfoControl.TB_Name.Text = rdata.Name; repeatingInfoControl.MouseLeftButtonUp += RepeatingInfoControl_MouseLeftButtonUp; repeatingInfoControl.Tag = k; repeatingInfoControl.RemoveClick += RepeatingInfoControl_RemoveClick; VPanel_Repeaters.Children.Add(repeatingInfoControl); k++; } if (data.RepeatingControls.Count > 0) { OpacityButton opacityButton = new OpacityButton(); opacityButton.Content = new Image() { Source = new BitmapImage(new Uri(@"pack://application:,,,/Resources/Icons/AddPlus.png")) }; RenderOptions.SetBitmapScalingMode(opacityButton, BitmapScalingMode.Fant); opacityButton.Width = 42; opacityButton.Height = 42; opacityButton.NormalOpacity = 1; opacityButton.HoverOpacity = 0.7f; opacityButton.ClickOpacity = 0.5f; opacityButton.Margin = new Thickness(0, 5, 0, 10); opacityButton.MouseLeftButtonUp += OpacityButton_MouseLeftButtonUp; VPanel_Repeaters.Children.Add(opacityButton); } }
private void RepeatingInfoControl_RemoveClick(RepeatingInfoControl sender) { data.RepeatingControls.RemoveAt((int)sender.Tag); UpdateAllControls(); }