I am creating a simple photo gallery application that displays images in a list. Xaml:
<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 the string [] of the paths of the JPEG image file.
When I use 10-11 images with a total size of 11 MB, the total memory usage reaches 500 MB !!! I am really surprised, as it is just an application for viewing photos without doing anything. Running this application makes my machine unusable.
I am using VS 2010 Express, .NET 4 on Vista. Can someone explain what happens in the background, which requires such a huge amount of memory? And what can be done to optimize it?
Thanks in advance.