向后拖动滑块时,在WPF中删除圆圈

时间:2018-10-23 17:39:53

标签: c# wpf slider

我有一个代码,可以使用滑块创建圆,但是我希望它在向后拖动时也将其删除。 这是我的代码:

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);

0 个答案:

没有答案