【发布时间】:2013-03-23 23:10:17
【问题描述】:
希望我能解释一下我需要什么以及问题是什么
我有以下列表框
<ListBox Margin="0,8,0,0" toolkit:TiltEffect.IsTiltEnabled="True" x:Name="ImageList" ItemsSource="{Binding Images}" HorizontalAlignment="Center" BorderThickness="4">
<ListBox.ItemTemplate>
<DataTemplate>
<Grid Background="{Binding imageID, Converter={StaticResource ImageConverter}}" Width="125" Height="125" Margin="6" Tap="list_OnTap">
<TextBlock Name="description" Foreground="{Binding TextColor}" Text="{Binding text}" Visibility="{Binding ShowText, Converter={StaticResource BooleanToVisibilityConverter}}" VerticalAlignment="Center" HorizontalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap"/>
<toolkit:ContextMenuService.ContextMenu>
<toolkit:ContextMenu IsZoomEnabled="False" Name="deletectx">
<toolkit:MenuItem Header="delete" Click="delete_Click"/>
</toolkit:ContextMenu>
</toolkit:ContextMenuService.ContextMenu>
</Grid>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
<toolkit:WrapPanel/>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
</ListBox>
</Grid>
上面的代码制作了一个图像网格,我使用网格背景来显示图像,因为我需要在图像上显示我的文本(不确定是否有其他方法可以做到这一点) 此页面加载大约 30 张图片,大小为 125x125 像素,每张大约 4kb。我注意到它消耗了大量的内存。我在这里阅读了一些关于清除图像缓存的帖子,但考虑到我将网格背景设置为我的图像而不是图像控件,我不知道我应该如何使用上述代码执行此操作。
我也许可以访问列表框内的网格,但无论我用它做什么,都只会应用于第一个图像而不是其余图像。我需要清除导航离开事件中的图像缓存。
另一个问题,我也有一些性能问题,进入这个页面需要一点时间,我在 Windows Phone App Analyser 中收到低帧率警告,不确定我在做什么(通过 Converter 为每个列表框项)是对还是错! 我怎样才能让它更快?
【问题讨论】:
-
欢迎来到 Stackoverflow!为您的问题选择标题时,无需在其中包含标签。请阅读meta.stackexchange.com/questions/19190 进行讨论以及为什么不需要它们。此外,最后的问候是不必要的,而是在您的联系人卡片中包含任何问候,它会显示在您所有问题的右下角。
标签: c# windows-phone-7 caching