DungeonMaster3000
DungeonMaster3000

Reputation: 21

Win 10 UAP - Drawing a Line to the Canvas

I'm playing around with the Win 10 UAP and trying to draw a Line to the Canvas in C# using the below code but doesn't work.

var line = new Line();
line.Stroke = new SolidColorBrush(Colors.LightSteelBlue);
line.StrokeThickness = 3;
line.Width = 50;

line.X1 = 0;
line.Y1 = 0;
line.X2 = 50;
line.Y2 = 0;

Canvas.SetTop(line, 50);
Canvas.SetLeft(line, 50);
TheCanvas.Children.Add(line);

Can someone please point me in the direction where I have gone wrong?

Many thanks, Tarran

Upvotes: 2

Views: 4581

Answers (1)

James He
James He

Reputation: 397

Comment this line works fine:

        var line = new Line();
        line.Stroke = new SolidColorBrush(Colors.Black);
        line.StrokeThickness = 3;
        //line.Width = 50;
        line.X1 = 0;
        line.Y1 = 0;
        line.X2 = 50;
        line.Y2 = 0;

        Canvas.SetTop(line, 50);
        Canvas.SetLeft(line, 50);


        TheCanvas.Children.Add(line);

Upvotes: 4

Related Questions