开发者

How to populate a Grid programatically in Silverlight?

开发者 https://www.devze.com 2023-03-16 02:29 出处:网络
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:

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

精彩评论

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

关注公众号