I have a LongListSelector which contains a image control which loads a lot of images from the web, this works fine for some time, but after i loaded some images i get out of memory exception. I read other people having the same issue regarding out of memory with a lot of images but still haven't found a solution. I have read that it has something to do with image/BitmapImage cache.
Here is my LongListSelector which contains the image control:
<phone:Pivot Title="MY APPLICATION">
<!--Pivot item one-->
<phone:PivotItem Header="Browse">
<Grid>
<phone:LongListSelector Name="llsGameList" ItemsSource="{Binding}" Tap="llsGameList_Tap" Margin="0,90,0,0">
<phone:LongListSelector.ItemTemplate>
<DataTemplate>
<Grid>
<Image Name="imgGameList" Margin="0,10,0,10" Stretch="Fill" HorizontalAlignment="Left" VerticalAlignment="Top" Height="200" Width="150">
<Image.Source>
<BitmapImage UriSource="{Binding BoxArtFrontThumb}"
CreateOptions="BackgroundCreation" DecodePixelHeight="200" DecodePixelWidth="150" />
</Image.Source>
</Image>
</Grid>
</DataTemplate>
</phone:LongListSelector.ItemTemplate>
</phone:LongListSelector>
</Grid>
</phone:PivotItem>
In my MainPage.xaml.cs i set the DataContext of my LongListSelector:
llsGameList.DataContext = gd.GetGamesListItems;
And here is the class i use to store my image in:
public class GetGamesList
{
public Uri BoxArtFrontThumb { get; set; }
}
Here is the ObservableCollection containing all the images:
private ObservableCollection<GetGamesList> _GetGamesListItems = new ObservableCollection<GetGamesList>();
public ObservableCollection<GetGamesList> GetGamesListItems
{
get
{
return this._GetGamesListItems;
}
}
I hope i explained it clearly. I really hope there is someone that can help me fix this memory problem. Thanks.