wpf ellipse点击后删除蓝色边框

时间:2016-04-18 22:34:39

标签: c# wpf xaml

我有一些省略号,当点击一个按钮时,我在cs文件中动态生成如下。问题是当我点击任何椭圆时,边框颜色变为蓝色,如图所示。如何删除蓝色背景请帮助。

enter image description here

private void btn1_Click(object sender, RoutedEventArgs e)
        {
            imgBrush.ImageSource = new BitmapImage(new Uri(@"pack://application:,,,/AthenaIsolatedFeatures;component/Widget/Pointers/top.png", UriKind.RelativeOrAbsolute));
            imgBrush.Stretch = Stretch.Fill;
            ele.Fill = imgBrush;
            lstBox.Items.Clear();
            CircularPanel.AngleRadians((sender as Button).Name);
            for (int i = 0; i < 4; i++) //Assuming 3 images to be created
            {
                ImageBrush brush = new ImageBrush();
                brush.ImageSource = new BitmapImage(new Uri(@"pack://application:,,,/AthenaIsolatedFeatures;component/Widget/SubImages/Target" + (i + 1) + ".png", UriKind.RelativeOrAbsolute));
                Ellipse ellipse = new Ellipse()
                {
                    Name = "Target" + i.ToString(),
                    Height = 70,
                    Width = 70,
                    Stroke = new SolidColorBrush(Colors.Black),
                    StrokeThickness = 1,

                };

                ellipse.Fill = brush;
                ellipse.MouseLeftButtonDown += Ellipse_MouseLeftButtonDown1;
                lstBox.Items.Add(ellipse);
            }
        }

现在,当点击每个动态生成的省略号时,我想做点什么

 private void Ellipse_MouseLeftButtonDown1(object sender, MouseButtonEventArgs e)
        {

          //Do something
        }

1 个答案:

答案 0 :(得分:0)

对于点击,而不是

ellipse.MouseLeftButtonDown += Ellipse_MouseLeftButtonDown1;

你可以尝试

e.MouseLeftButtonDown += Ellipse_MouseLeftButtonDown1;

对于后台,您可以尝试使用XAML代码

<Ellipse Width="50" Height="50" Stroke="Blue" StrokeThickness="10" Fill="Transparent"></Ellipse>

希望这有帮助。