我想通过C#
应用的Windows-Phone 8
代码为一行添加文字。这甚至可能吗?我在循环中有如下几行 -
Line[] l = new Line[300];
int cnt=0;
for(int i=0;i<20;i++)
{
for(int j=0;j<24;j++)
{
l[cnt] = new Line();
text1[cnt] = new TextBlock();
l[cnt].X1 = centre_X[i];
l[cnt].Y1 = centre_Y[i];
l[cnt].X2 = centre_X[j];
l[cnt].Y2 = centre_Y[j];
---
---
Here I want to insert the text say "Hello"
---
Canvas12.Children.Add(l[cnt]);
}
}
那么,有没有办法通过在行的中心添加一些textbox
或其他方式来添加一些文本?
答案 0 :(得分:0)
您需要将行和文本块放在某个容器中,例如网格。然后,您将网格添加到画布中。试试这个
var grid = new Grid();
var text = new TextBlock { Text = "Hello" };
grid.Children.Add(l[cnt]);
grid.Children.Add(text);
Canvas12.Children.Add(grid);