UWP在按钮下画一条线

时间:2016-02-10 13:06:07

标签: uwp

我试图在两个按钮之间画一条线,但这条线位于按钮的顶部。我该怎么在按钮下面做? 任何人都可以帮助我吗?

picture here

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

    }

1 个答案:

答案 0 :(得分:1)

在按钮和行上设置Canvas Z索引,使得行的Z索引低于按钮的Z索引。

<Button Canvas.ZIndex="2" />

或代码

Canvas.SetZIndex(someButton, 2);