Question

I already read this thread, but I don't figure out what BitmapCache does.

According to 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.

I set CacheMode="BitmapCache" for my ListBox. I think that after the 1st render, the OS will save its visual as a bitmap, then continue to show that bitmap in each frame, without render it again. I think the ListBox should be static now. But I can still scrolling the Listbox.

I must understand it wrong. Please explain what BitmapCache does ?

If it is good, why don't we set BitmapCache for every element ?

Was it helpful?

Solution

I think the ListBox should be static now. But I can still scrolling the Listbox.

When you scroll the listbox, it redraws its content, thus updating the cached representation. The bitmap cache is useful for some transformations, like a translation. In those cases, the cached representation has many advantages:

  1. The control doesn't have to redraw its content => CPU economy
  2. Since the visual representation isn't dependent of the control anymore, it can be handled directly by the GPU

If it is good, why don't we set BitmapCache for every element ?

BitmapCache uses more memory, and it seems there's corner cases where it can actually have a negative performance impact (though I'm not knowledgeable enough on the subject to enumerate them). A good way to know if BitmapCache should be turned on is to set the EnableRedrawRegions setting to true. The emulator will then show which areas are redrawn, and you can set the BitmapCache accordingly.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top