yuntian liu
yuntian liu

Reputation: 61

UWP draw a line under the button

I tried to draw a line between two buttons, but this line is on top of the button. how can I make it under the buttons? Can anyone help me?

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

    }

Upvotes: 1

Views: 647

Answers (1)

Igor Ralic
Igor Ralic

Reputation: 15006

Set Canvas Z index on buttons and line so that the Z index of line is lower than the Z index of buttons.

<Button Canvas.ZIndex="2" />

or in code

Canvas.SetZIndex(someButton, 2);

Upvotes: 1

Related Questions