简体   繁体   中英

Image doesn't appear when changing its source in Windows Phone

When I want to change an image's source, the image simply disappears.

The code I'm using:

tactImg.Source=tactImgList[i];

tactImgList = new BitmapImage[32];
tactImgList[0] = new BitmapImage(new Uri("ms-appx:///Assets/Images/1.png", UriKind.Absolute));

What am I doing wrong? Is there something I need to add to an xaml file or I'm making the global array wrong?

You don't need to use ms-appx in Windows Phone 8 projects , it's for WinRT projects.

Make sure your image's Build type is Content , remove the ms-appx part and since your image has relative uri , set your UriKind to Relative.

First, fill in the data, and then change the source. tactImgList = new BitmapImage[32]; tactImgList[0] = new BitmapImage(new Uri("ms-appx:///Assets/Images/1.png", UriKind.Absolute)); tactImg.Source=tactImgList[i];

Or use ObservableCollection for storing images.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM