I am building a simple photo gallery application which shows images in a listbox. The xaml is:
<ListBox x:Name="imageList" Margin="10,10" ItemsSource="{Binding}" Height="500">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding}" HorizontalAlignment="Left"></TextBlock>
<Image Source="{Binding}" Width="100" Height="100" HorizontalAlignment="Center"></Image>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
The DataContext set here is a string[] of JPEG image file paths.
When I use 10-11 images with a total size of 11 MB, the total memory usage goes up to 500 MB!!! I am really surprised, as this is just a simple photo viewing app doing nothing else. Running this app makes my machine pretty unusable.
I am using VS 2010 express, .NET 4 on Vista. Can any one please explain what is happening in the background which requires such a huge memory footprint? And what can be done to optimize it?
Thanks in advance.