包含图像的ListboxItems - 内存问题

时间:2011-11-24 23:20:25

标签: windows-phone-7 listboxitem

我的视图中的列表框存在设计问题。 目前它已将DataTemplate作为ItemTemplate:

<DataTemplate x:Key="MovieItemTemplate">
    <StackPanel>
        <Border BorderBrush="{StaticResource PhoneForegroundBrush}" BorderThickness="5" Margin="3" Height="215" Width="140">
            <Image x:Name="MovieCover"                                                                                
                    toolkit:TiltEffect.IsTiltEnabled="True"
                    Margin="0"
                    HorizontalAlignment="Center"
                    Width="140"
                    Height="210">
                <Image.Source>
                    <BitmapImage UriSource="{Binding Cover}" CreateOptions="BackgroundCreation"/>
                </Image.Source>
                <interactivity:Interaction.Triggers>
                    <interactivity:EventTrigger EventName="Tap">
                        <gsextra:EventToCommand Command="{Binding MainViewModel.MovieItemSelectedCommand, Source={StaticResource Locator}}"
                                                PassEventArgsToCommand="True"
                                                CommandParameter="{Binding MovieID}"
                                                ></gsextra:EventToCommand>
                    </interactivity:EventTrigger>
                </interactivity:Interaction.Triggers>
            </Image>
        </Border>
    </StackPanel>
</DataTemplate>

正如您所看到的,我内部有一个图像,可以通过URI从互联网上下载他的内容。感谢新的芒果选项BackgroundCreation(cfr。http://blogs.msdn.com/b/slmperf/archive/2011/06/13/off-thread-decoding-of-images-on-mango-how-it-impacts-you-application.aspx),它在后台加载。

但我有一个非常大的集合,即使我'分页'Listbox Source的绑定,我注意到我的内存一直在上升,直到它消耗了所有内容并且应用程序崩溃。

然后,我注意到这个http://blog.wpfwonderland.com/2011/01/17/images-and-memory-leaks-in-windows-phone-7/因此我需要清理图像本身,因为wp7中的图像缓存功能。

当我这样做时,一切都很好地参考了内存,但现在每次用户“页面”通过列表框时,图像需要重新下载,导致应用程序几乎无法使用...因为用户继续等待那些图像。

有关如何解决此问题的任何提示/技巧?

我也试过了DefferedLoadListBox

0 个答案:

没有答案