在WP7上經歷了兩個小時的SL網格鬥爭。我使用下面的代碼建立自己的網格:WP7 Silverlight網格未顯示內容
public void initUIBoard() { int x, y; Button b;
for (x = 0; x < mine.cRows; x++) {
RowDefinition rd = new RowDefinition();
rd.Height = new GridLength(20);
uiBoard.RowDefinitions.Add(rd);
}
for (y = 0; y < mine.cColumns; y++) {
ColumnDefinition cd = new ColumnDefinition();
cd.Width = new GridLength(20);
uiBoard.ColumnDefinitions.Add(cd);
}
for (x = 0; x < mine.cRows; x++)
for (y = 0; y < mine.cColumns; y++)
{
b = new Button();
b.Click += new RoutedEventHandler(this.caseClick);
b.Tag = mine.gameBoard[x][y];
Grid.SetRow(b, x);
Grid.SetColumn(b, y);
uiBoard.Children.Add(b);
}
}
的事情是,我的網格顯示爲空,我做得不對這些行/列的定義還是什麼?
在此先感謝
謝謝!明白了你的觀點 – CoolStraw 2010-10-27 08:59:06