在WinForm中,我使用这样的图形:
public partial class Form1 : Form
{
Graphics g;
int r = 80; int c = 80; int dd = 20; int[,] arr; int d = 10; int flag;
public Form1()
{
InitializeComponent();
arr = new int[r, c];
SetArr(arr, r, c);
}
private void Form1_Paint(object sender, PaintEventArgs e)
{
g = this.CreateGraphics();
for (int i = 0; i <= r; i++)
g.DrawLine(new Pen(Color.Blue, 1), 0, i * dd, r * dd, i * dd);
for (int j = 0; j <= c; j++)
g.DrawLine(new Pen(Color.Blue, 1), j * dd, 0, j * dd, c * dd);
}
...
}
有人能告诉我如何在Windows Phone中绘制相同的行吗?
答案 0 :(得分:2)
在您的XAML代码中添加<Grid x:Name="grid" />
,然后使用XAML添加行:
<Line Stroke="Blue" StrokeThickness="1" X1="1" X2="2" Y1="16" Y2="18" />
或通过代码:
Line line = new Line();
line.Stroke = Colors.Blue;
line.StrokeThickness = 1;
line.X1 = 1;
line.X2 = 2;
line.Y1 = 16;
line.Y2 = 18;
grid.Children.Add(line);