Bound Image Control not updating when file changes
-
sabato 28 aprile 2012 05:44
I'm having a problem where my Image control that is bound to a Uri is not updating the displayed picture after the first time.
I allow users to select an picture using the file picker and save that image. To keep things clean I reuse the same file name. I can see that the bindings are firing for the "SmallImage" property so the image control should update, but it only works the first time. Its like there is something built into the image control that sees its the same file name so its doesn't update.
Any ideas?
<Image Stretch="UniformToFill" HorizontalAlignment="Center" VerticalAlignment="Center"> <Image.Source> <BitmapImage UriSource="{Binding SmallImage}" /> </Image.Source> </Image>
Tutte le risposte
-
sabato 28 aprile 2012 07:36
You are right. Images get cached for memory optimisation and to speed up load time. I don't know if there is a way to rest image cache or force reloading of image file. You could open image as file and load it into WriteableBitmap thou, that would bypass image cacheing.- Contrassegnato come risposta Matt SmallMicrosoft Employee, Moderator mercoledì 2 maggio 2012 13:21
-
domenica 27 maggio 2012 11:39
FYI If you want to keep the same bitmapname and not have it cached you can add a trailing querystring to the filename.
EG "MyCachedBitmapImage.png" becomes "MyCachedBitmapImage.png?Cache=None;
By varying the value of the querystring (WG with DateTime.Now.Hours or DateTime.Now.Ticks etc) you can get pretty good control over the default caching mechanism.
Ian
- Proposto come risposta Ian G Walker domenica 27 maggio 2012 11:39

