2
我想創建一個動態的網格到頁面。我正在使用此代碼:在Windows Phone 8中創建動態網格
Grid grd = new Grid();
for (int i = 0; i <MAX_X; i++)
{
grd.RowDefinitions.Add(new RowDefinition());
}
for (int i = 0; i <MAX_Y; i++)
{
grd.ColumnDefinitions.Add(new ColumnDefinition());
}
for (int x = 0; x <= MAX_X; x++)
{
for (int y = 0; y <= MAX_Y; y++)
{
TextBlock t = new TextBlock();
t.SetValue(Grid.RowProperty, x);
t.SetValue(Grid.ColumnProperty, y);
t.text = "Hello";
grd.Children.Add(t);
}
}
它已創建但未顯示任何內容。當我做調試,其工作正常,但它不顯示在我的頁面。我錯過了什麼?