我想知道在向画布添加子项之前是否有办法刷新画布?我有这个代码,它给我画了一个带有浅蓝色笔划的黑色椭圆。现在我想在程序启动时更改 StrokeThickness(我有一个滑块来定义 StrokeThickness)。问题是 StrokeThickness 发生了变化,但前提是我重绘了椭圆,但我希望在移动滑块时进行更改。有任何想法吗?谢谢!
//this code is in canvas_MouseDown
double smt = sliderThickness.Value;
//krog
elip = new Ellipse
{
Width = 100,
Height = 100,
Fill = Brushes.Black,
Stroke = Brushes.LightBlue,
StrokeThickness = smt,
};
Canvas.SetLeft(elip, mouseX - 50);
Canvas.SetTop(elip, mouseY - 50);
canvas1.Children.Add(elip);