How to set a placeholder for an Image control (while it is loading)?

I have an application that displays a list of images. The image source is set to an http address, and the images are uploaded and displayed automatically.

However, while the application takes time to download, image management does not show anything. Therefore, the user approach is not suitable.

How can I display a loading placeholder image or loading indicator for each image control?

+4
source share
4 answers

While the image is loading, it is displayed transparently. You can take advantage of this to display the item below the image while it is loading. For example, you might have a stock image associated with your XAP, which is the default avatar, for example. Or you can display the XAML boot animation. Then, when the image is completed, it will close the element behind it.

Mick's suggestion is good if you need to minimize your visual tree, and if your script allows you to use a code solution. This proposal is not perfect, but makes it easier to work with the case when the image of your placement is not scaled / centered, but the downloaded image is scaled / stretched.

+5
source

You can set the image source to your placeholder, and then when ImageOpened starts up, change it to the remote URL and let it run it.

+2
source

In addition to the other two sentences (from Josh and Mick), you can display the placeholder in xaml and then download the actual desired image in the background using HttpWebRequest . Then, when the image is fully loaded, save it in isolated storage, and then update the source to the displayed image.

Yes, it is more complicated than other solutions, but it will simplify the visual tree and avoid displaying a blank image during image loading.
It will also give you offline image caching.

0
source

I wonder how many options are there to solve this problem.

You might also like the Ben Gracewood image caching implementation, or what seems to be a development of this idea in the blog comments.

One-time cached images in Windows Phone 7 "Ben.geek.nz

Peter Novax Mobile Blog - Intelligent Image Caching for WP 7

Some background to the discussion leading to this here, if it is of interest.

Image Management Cache Duration?

0
source

Source: https://habr.com/ru/post/1332060/


All Articles