Hello,
Welcome to our Microsoft Q&A platform!
By examining your code, you can consider fixing some details, which should improve the responsiveness of your code.
1. Please use BitmapImage.SetSourceAsync()
Use asynchronous methods to keep the UI responsive and not get stuck.
2. Please limit the resolution of BitmapImage
Assume that the size of the Image
control in your GridView
is 200x200, but the resolution of the local image is 500x500. If you do not set the resolution, the application will load the 500x500 image, but only display the 200x200 area, which will greatly increase the memory consumption.
Try this:
var bitmapImage = new BitmapImage();
bitmapImage.DecodePixelWidth = 200;
await bitmapImage.SetSourceAsync(thumbnailStream);
3. Don't break the GridView's virtualization
Virtualization can greatly reduce the memory burden because it only loads entries in the current window area. But if you add a layer of ScrollViewer
outside the GridView
, it will break the default virtualization.
I don't know if you did a similar operation. If not, you can try the previous two methods, which should improve the performance of the application.
Thanks.