Ruby Kousinovali
Ruby Kousinovali

Reputation: 347

Image not Refreshing from http url in image control in wp7

I have an app with following code

    url = "http://mywebsite/image.jpg";
    Uri uri = new Uri(url, UriKind.Absolute);
    image1.Source = new BitmapImage(uri);

The problem is that the image is not refreshing after loading again and again its always the same. How can i refresh it? Thanks

Upvotes: 0

Views: 508

Answers (1)

Pedro Lamas
Pedro Lamas

Reputation: 7233

This is due to the default behavior of an Image control in Windows Phone "Mango" is to cache the image.

If you add an image like this:

<Image Source="http://domain/image.png" />

It will have a default behavior like this:

<Image>
    <Image.Source>
        <BitmapImage CreateOptions="DelayCreation" UriSource="http://domain/image.png" />
    </Image.Source>
</Image>

As you can see here, this is controlled with the BitmapImage.CreateOptions property.

In your case, you should just change the default behavior to something like this:

<Image>
    <Image.Source>
        <BitmapImage CreateOptions="DelayCreation,IgnoreImageCache" UriSource="http://domain/image.png" />
    </Image.Source>
</Image>

Upvotes: 2

Related Questions