0

我想知道如何将图像设置为“grid_Main”,如果我在循环中创建了所有图像(参见代码)。

代码:

private void MoleImageMaker()
{
    NumofImages = TUtils.GetIniInt(Moleini, "NumPictures", "pictures", 8);
    String MoleImageFunction = TUtils.GetIniFileString(Moleini, "ImagePath", "PictureFile", Root + "mole2.png");

    for (int i = 0; i < NumofImages; i++)
    {
        Image mole = new Image();
        mole.Source = new BitmapImage(new Uri(MoleImageFunction));
        mole.Name = "Mole" + i;
    }
}
4

1 回答 1

2

像这样的东西

for (int i = 0; i < NumofImages; i++)
{
  Image mole = new Image();
  mole.Source = new BitmapImage(new Uri(MoleImageFunction));
  mole.Name = "Mole" + i;  
  Grid.SetColumn(mole, i);
  grid_Main.Children.Add(mole);
}
于 2013-05-30T18:37:38.500 回答