在Windows Phone中更改其来源时,图像不会出现
本文关键字:图像 Phone Windows | 更新日期: 2023-09-27 17:52:41
当我想更改图像的来源时,图像就会消失。
我使用的代码:
tactImg.Source=tactImgList[i];
tactImgList = new BitmapImage[32];
tactImgList[0] = new BitmapImage(new Uri("ms-appx:///Assets/Images/1.png", UriKind.Absolute));
我做错了什么?是否有一些我需要添加到一个xaml文件或我使全局数组错误?
你不需要在Windows Phone 8项目中使用ms-appx,它适用于WinRT项目。
确保你的图像的构建类型是Content,删除ms-appx部分,因为你的图像有相对uri,设置你的UriKind为relative。
首先填写数据,然后更改源。
tactImgList = new BitmapImage[32];
tactImgList[0] = new BitmapImage(new Uri("ms-appx:///Assets/Images/1.png", UriKind.Absolute));
tactImg.Source=tactImgList[i];
或者使用ObservableCollection
存储图像