[英]Image doesn't appear when changing its source in Windows Phone
当我想更改图像来源时,图像会消失。
我正在使用的代码:
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项目。
确保图像的Build类型为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
来存储图像。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.