我有一个代码,可以使用滑块创建圆,但是我希望它在向后拖动时也将其删除。 这是我的代码:
private void Slider_ValueChanged(object sender, RoutedPropertyChangedEventArgs<double> e)
{
int marginLeft = (caPaper.Children.Count * 35);
Random rd = new Random();
byte r = (byte)rd.Next(0, 256);
byte g = (byte)rd.Next(0, 256);
byte b = (byte)rd.Next(0, 256);
Ellipse newBall = new Ellipse();
newBall.Fill = new SolidColorBrush(Color.FromRgb(r,g,b));
newBall.Height = 30;
newBall.Width = 30;
newBall.Margin = new Thickness(marginLeft, 100, 0, 0);
caPaper.Children.Add(newBall);