希望我能解释我需要什么以及问题是什么
我有以下列表框
<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 为每个列表框项加载图像)对不对!我怎样才能让它更快?