如果我在循环中创建了所有图像,我想知道如何将图像设置为“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;
}
}
答案 0 :(得分: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);
}