2015-06-02 47 views
0

當我想更改圖像的來源時,圖像就會消失。在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文件或我讓全局數組錯了嗎?

回答

0

您不需要在Windows Phone 8項目中使用ms-appx,它適用於WinRT項目。

確保您的圖像的構建類型是內容,刪除ms-appx部分,並且由於您的圖像具有相對uri,請將您的UriKind設置爲Relative。

0

首先填寫數據,然後更改來源。 tactImgList = new BitmapImage[32]; tactImgList[0] = new BitmapImage(new Uri("ms-appx:///Assets/Images/1.png", UriKind.Absolute)); tactImg.Source=tactImgList[i];

或者使用ObservableCollection存儲圖像。

相關問題