0

I have 30000 pictures,now I need a control that can show me the image(as a pictures not just the file path) with its files name.

Need some kind of paging e.g. 30 pictures a page, I thought of GridView ?!

I have a list which contains a Hashtable(key: escaped path to that picture, value: picture name), I have a GridView which is bound to that hashtable, but it show only the file path.

c#:

wordListView.ItemsSource = Hsh;// contains a property of Hahstable;

XAML:

      <DataGrid x:Name="wordListView" HorizontalAlignment="Left" VerticalAlignment="Top" Height="260" Width="645" Margin="10,156,0,0">
        <!--AutoGenerateColumns="False" ItemsSource="{Binding}">-->
        <!--<DataGrid.Columns>
            <DataGridTextColumn Binding="{Binding ID}"   Header="ID" IsReadOnly="True" />
            <DataGridTextColumn Binding="{Binding Path}"  Header="Path"/>
            <DataGridTextColumn Binding="{Binding TimeStamp}"   Header="TimeStamp"/>
        </DataGrid.Columns>-->
    </DataGrid>
BlaBlub
  • 11
  • 3

1 Answers1

0

Performance will be terrible if you try to load all the images into memory at once. Therefore you can use virtualisation to only load those that will be visible (or are just off the screen) and load others if/when the user scrolls to make them visible.

This answer contains some example code. In a nutshell you need to set the ItemsPanel to a VirtualizingStackPanel:

<ItemsControl
    VirtualizingStackPanel.IsVirtualizing="True"
    ScrollViewer.CanContentScroll="True"
    ItemsSource="{Binding MyItems}">
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <Image Source="{Binding ImageSource}" />
        </DataTemplate>
    </ItemsControl.ItemTemplate>
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <VirtualizingStackPanel />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
</ItemsControl>

You can read more about optimising performance on MSDN here.

Community
  • 1
  • 1
Drew Noakes
  • 300,895
  • 165
  • 679
  • 742