wp7 使用缓存 改善性能
1 <Grid > 2 <!-- <Grid.CacheMode> 3 <BitmapCache RenderAtScale="0.5" /> 4 </Grid.CacheMode> --> 5 <Grid HorizontalAlignment="Center"> 6 <Image Name="BackgroundImage" Source="/resources/Images/LargerImageLoading1.png" MaxWidth="400" Stretch="None" VerticalAlignment="Center"/> 7 <Border BorderBrush="#bbbbbb" BorderThickness="3" Width="{Binding imgWidth}" Height="{Binding imgHeight}" MaxWidth="410" MaxHeight="2000" > 8 <Image Margin="5" Source="{Binding imgSource}" Width="{Binding imgWidth}" DoubleTap="PleasureListImage_DoubleTap" Stretch="Uniform" MaxWidth="400" > 9 10 </Image> 11 </Border> 12 </Grid>
注: 对于移动开发来说,有时候内存占用反而增加就像上面代码中缓存图片,这样没有意义,除非是缓存整个页面但是如果设置 RenderAtScale 小于1 会使文字模糊
参考:
http://msdn.microsoft.com/zh-cn/library/ie/ee230083.aspx
http://msdn.microsoft.com/zh-cn/library/ie/system.windows.media.bitmapcache.aspx