Hi all. I'm having issues with a image displayer in WPF. I've a ListView displaying ImageSources.
<Setter Property="ItemsPanel">
<Setter.Value>
<ItemsPanelTemplate>
<WrapPanel />
</ItemsPanelTemplate>
</Setter.Value>
</Setter>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBox}">
<Border x:Name="Bd" SnapsToDevicePixels="true" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="1">
<ScrollViewer Padding="{TemplateBinding Padding}" Focusable="false">
<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
</ScrollViewer>
</Border>
<ControlTemplate.Triggers>
<Trigger Property="IsEnabled" Value="false">
<Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
</Trigger>
<Trigger Property="IsGrouping" Value="true">
<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
</Trigger>
</ControlTemplate.Triggers>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="ImagesListerViewItemsTemplate" DataType="{x:Type ImageSource}" >
<Border Height="150" Width="150" CornerRadius="0,0,0,0" BorderThickness="1,1,1,1" Margin="4,4,4,4" BorderBrush="#FF000000">
<Border Margin="8,8,8,8" Background="#FFFFFFFF">
<Border.BitmapEffect>
<OuterGlowBitmapEffect GlowColor="#FFFFFFFF"/>
</Border.BitmapEffect>
<Image Source="{Binding}" />
</Border>
</Border>
</DataTemplate>
And to load the pictures :
private static BitmapImage LoadDisplayableImage(System.IO.FileInfo file)
{
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.DecodePixelWidth = 100;
bi.DecodePixelHeight = 100;
bi.UriSource = new Uri(file.FullName);
bi.EndInit();
return bi;
}
But then my program is very slow when a want to scroll the ListView or when i try to resize the form with only 49 images. In comparison, Windows' Explorer can load up to 3000 images in my computer and display them all and is still very fast when i scroll it (faster than my 49 picture little sample).
So how can i achieve the same speed or approach it ?