我有一個視圖,我有一個列表框。嘗試使用url-s中的約5000張圖片填充它。我有這些圖像的列表,但是當我嘗試綁定它時,我必須等待很多時間才能看到圖像。它非常緩慢地顯示圖像。如何從url綁定大量的圖像wpf c#?
public static FileDto MapToFileDto(this FileUploadedResponzeJsonDto resp)
{
var dto = new FileDto();
dto.Delete_url = resp.Delete_url;
dto.File_ID = resp.File_ID;
dto.FileName = resp.Name;
dto.FileSizeInBytes = resp.FileSizeInBytes;
dto.Info_url = resp.Info_url;
dto.Url = resp.Url;
dto.Visits = resp.Visits;
if(!string.IsNullOrEmpty(resp.Surl) && resp.Name.HasImageExtension())
dto.DisplayImage = new System.Windows.Media.Imaging.BitmapImage(new Uri(string.Format(ClientConstans.API_URL_GET_SMALL_IMAGE, resp.Surl)));
return dto;
}
這使得URL-S這樣的:
string.Format(ClientConstans.API_URL_GET_SMALL_IMAGE, resp.Surl)
// https://mysite/image.png
我充滿FileDto列表,並將其綁定到列表框。它快速創建列表,但是我必須等待很多圖像。
如果我想立即展示圖片,我應該如何填充圖片列表框? (他們真的很小的圖像,大約4kb /圖像)
而我有另一個問題,我不能打破連接。當我清除列表並嘗試重新填充時,我無法做到這一點。它引發我只是一個例外,因爲URI綁定。
嘗試將圖像加載到後臺線程上並同時下載圖像 – User2012384