开发者

How to populate a Grid programatically in Silverlight?

I have a Grid I am trying to create and populate programatically in Silverlight. However, all of the items just default to spot "0, 0" in the grid despite my efforts. This is what I have:

Grid holdingGrid = new Grid();
int row = 0;

for (int i = 0; i < 10; i++) {
   Expander e开发者_如何学Goxpander = new Expander();
   holdingGrid.Children.Add(expander);
   Grid.SetRow(expander, row);
   Grid.SetColumn(expander, 0);
   row++;
}

But this still causes all of the items to pile up in the first row and the first column. What am I doing wrong?


Grid holdingGrid = new Grid();
int row = 0;

for (int i = 0; i < 10; i++) {
   Expander expander = new Expander();
   holdingGrid.RowDefinitions.Add(new RowDefinition());
   holdingGrid.Children.Add(expander);
   Grid.SetRow(expander, row);
   Grid.SetColumn(expander, 0);
   row++;
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜