我试图在两个按钮之间画一条线,但这条线位于按钮的顶部。我该怎么在按钮下面做? 任何人都可以帮助我吗?
public void CreateALine(double x1, double y1)
{
// Create a Line
Line redLine = new Line();
redLine.X1 = x + 20;
redLine.Y1 = y + 20;
redLine.X2 = x1 + 20;
redLine.Y2 = y1 + 20;
SolidColorBrush gBrush = new SolidColorBrush();
gBrush.Color = Colors.Yellow;
// Set Line's width and color
redLine.StrokeThickness = 2;
redLine.Stroke = gBrush;
// Add line to the Canvas
canvas2.Children.Add(redLine);
}
答案 0 :(得分:1)
在按钮和行上设置Canvas Z索引,使得行的Z索引低于按钮的Z索引。
<Button Canvas.ZIndex="2" />
或代码
Canvas.SetZIndex(someButton, 2);