1

Currently my FlipView allows the user to select multiple pictures from the local Pictures folder and then display the selected images in FlipView. However it will only work if the user selects a small number of pictures. When too many large images are selected, the app crashes. I read that VirtualizingStackPanel stores the 3 images in memory (before, current, after) so that not all of the images are being loaded at once.

This is my FlipView (edited on November 14th).

<FlipView x:Name="flpView" Grid.Row="1" Margin="10, 10, 10, 10">
        <FlipView.ItemsPanel>
            <ItemsPanelTemplate>
                <VirtualizingStackPanel Orientation="Horizontal"/>
            </ItemsPanelTemplate>
        </FlipView.ItemsPanel>

        <FlipView.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <Image Source="{Binding}" Stretch="Uniform"/>
                </Grid>
            </DataTemplate>
        </FlipView.ItemTemplate>
    </FlipView>
Poji
  • 39
  • 7

1 Answers1

0

Yes, if you use a VirtualizingStackPanel it will reuse the Ítems, and if you won't have problems with large data collections. Try this:

  <FlipView HorizontalAlignment="Left" Height="464" Margin="718,288,0,0" VerticalAlignment="Top"  ItemsSource="{Binding YourSource}" ItemTemplate="{StaticResource ImageTemplate}">
        <FlipView.ItemsPanel>
            <ItemsPanelTemplate>
                <VirtualizingStackPanel/>
            </ItemsPanelTemplate>
        </FlipView.ItemsPanel>
    </FlipView>
Fritjof Berggren
  • 3,178
  • 5
  • 35
  • 57
  • Hmm.. what happens if I only have Source="{Binding}" and not ItemsSource="{Binding MySource}"? – Poji Nov 12 '13 at 15:23
  • The Image doesn't have an ItemsSource property, the DataTemplate remains as you pointed in your post, but the FlipView XAML would look like what I posted. – Fritjof Berggren Nov 12 '13 at 15:26
  • Hi there. I updated my codes as shown above but it still doesn't work :c – Poji Nov 14 '13 at 04:50