Multiple images from folder

前端 未结 3 870
深忆病人
深忆病人 2020-12-22 00:20

as I\'m fairly new to C# and WPF I just can\'t figure out how to do this. I have a form that should show 151 images (all pokemon generation 1 sprites) in a form. The way I\'

3条回答
  •  难免孤独
    2020-12-22 01:18

    You need to define your bitmap inside the loop, not outside. Then each iteration will create a new bitmap with the new path.

    so something like:

    for (int i = 0; i < imgCount; i++)
    {
       // padding left will give you 001 and 010 and 151
       string img = i.ToString().PadLeft(3, '0');
       BitmapImage carBitmap = new BitmapImage(new Uri("pack://application:,,,/Images/All_Sprites/" + img+".png", UriKind.Absolute));
       // the rest of your code
    }
    

提交回复
热议问题