繁体   English   中英

在Windows Phone中更改其来源时图像未出现

[英]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.

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