Well, it took me a while to get back to this issue. I will share my findings here, but I do not see them as a real answer to this question, but rather a workaround. However, I hope this helps someone.
First, I want to confirm that an OutOfMemoryException occurs in certain circumstances. But, surprisingly, it depends on the page layout you use. In fact, if your layout includes a StackPanel , you will get an exception. I suppose it comes down to how the MeasureOverride and ArrangeOverride implemented in the StackPanel (although I may be completely wrong here). It appears that when the ListBox is a child of the StackPanel , it tries to load all the images before displaying it. This, of course, causes a memory leak.
On the other hand, if you use something like a Grid as a parent for a list of images, then there are no such exceptions, and memory loading is reasonable.
Here is the page layout that worked for me:
<Grid> <ListBox ItemsSource="{Binding IsoStorePics}"> <ListBox.ItemTemplate> <DataTemplate> <Image local:IsoStoreImageSource.IsoStoreFileName="{Binding Path}" Margin="5"/> </DataTemplate> </ListBox.ItemTemplate> </ListBox> </Grid>
This is the best answer I have for you now. Please let me know if this helps.
Haspemulator
source share