Reputation: 14310
In my UWP app I have an issue where sometimes not all images are loaded. It is usually one or two images, but I have seen it go to at least 5.
When an image is gone (for example in a ListView
), all the images that point to the same file are gone. For example a ListViewItem
has a cross in the right-hand corner, it is either there for the entire list or not at all for the entire list.
It takes a while to reproduce (10 to 30 minutes), but I always get the issue. My app does not go over 100MB in debug mode and all images are local (the app is not connected to the internet).
Sometimes the images are loaded by directly (hardcoding) the image in the XAML like so:
<Image Source="/Assets/Images/BackButton.png"/>
Or sometimes by having a binding to a property in my class:
<Image Source="{Binding Image}"/>
public string Image { get; set; }
Both of these loading methods cause the image not to show up sometimes.
My users have also reported text not showing up correctly, but I have not been able to reproduce that one. I mention it because it might be related.
EDIT: I have noticed that when the computer is in a low-memory state (ex: other programs are using 90% of the computer's memory) the images get removed. Is there a way to disable removal of the images to free up memory?
Upvotes: 1
Views: 2082
Reputation: 31724
Setting CacheMode="BitmapCache"
on the images might work around a possible platform bug that would cause it.
If the issue is caused by memory pressure - you might want to make sure to use lower resolution images and use images that are at resolution appropriate to your screen resolution. At the very least - you might want to look into things like DecodePixelWidth
to ensure the resolution at which the images are loaded isn't too high.
Upvotes: 2