本帖最后由 赵科铭 于 2014-3-20 00:32 编辑
- for (int i = 0; i < 10; i++)
- {
- ColumnDefinition colDef = new ColumnDefinition();
- gridGame.ColumnDefinitions.Add(colDef);
- RowDefinition rowDef = new RowDefinition();
- gridGame.RowDefinitions.Add(rowDef);
- }
复制代码- for (int i = 0; i < 10; i++)
- {
- for (int j = 0; j < 10; j++)
- {
- Image img = new Image();
- Random rand = new Random();
- int imgNum = rand.Next(1,10);//随机生成1-9的数
- img.Source = new BitmapImage(new Uri("imgs/"+imgNum+".jpg",UriKind.Relative));
- Grid.SetRow(img,i);
- Grid.SetColumn(img,j);
- gridGame.Children.Add(img);
- }
- }
复制代码
为什么生成图片是这样的?
|