win10 UAP -绘制一条线到画布
本文关键字:一条 UAP 绘制 win10 | 更新日期: 2023-09-27 18:10:06
我正在玩win10 UAP,并试图在c#中使用下面的代码在画布上画一条线,但不起作用。
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);
谁能告诉我哪里走错了吗?很多谢谢,Tarran
注释这行可以正常工作:
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);