我已经读过this thread ,但我不知道 BitmapCache
是做什么的。
根据msdn ,
Bitmap caching allows visual elements to be stored as bitmaps after the first render pass. After the element is cached, the application bypasses the render phase for the cached visual element and displays the stored bitmap instead.
我为我的ListBox
设置了CacheMode="BitmapCache"
。我认为在第一次渲染后,操作系统会将其视觉效果保存为位图,然后继续在每一帧中显示该位图,而无需再次渲染它。我认为 ListBox
现在应该是静态的。但我仍然可以滚动 Listbox
。
我一定理解错了。请解释一下 BitmapCache
的作用是什么?
如果它很好,为什么我们不为每个元素设置 BitmapCache
呢?
最佳答案
I think the ListBox should be static now. But I can still scrolling the Listbox.
当您滚动列表框时,它会重新绘制其内容,从而更新缓存的表示形式。位图缓存对于某些转换很有用,例如翻译。在这些情况下,缓存表示有许多优点:
- 控件不必重绘其内容 => CPU 经济
- 由于视觉表示不再依赖于控件,因此可以直接由 GPU 处理
If it is good, why don't we set BitmapCache for every element ?
BitmapCache 使用更多内存,而且似乎在某些极端情况下它实际上会对性能产生负面影响(尽管我对这个主题的了解不够,无法一一列举)。了解是否应打开 BitmapCache 的一个好方法是将 EnableRedrawRegions
设置设置为 true。然后模拟器将显示哪些区域被重绘,您可以相应地设置 BitmapCache。
关于windows-phone-7 - WP7 中的 BitmapCache 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13951942/