简体   繁体   中英

BitmapCache poor performance while resizing

I have a ListView with different complex ListViewItem containers consisting of images, shadow effects, blur effects.. etc. Rendering these containers in large amounts heavily reduces performance, especially since i'm using a blur overlay frame on top of the ListView . Which is why in this case i'm setting CacheMode to BitmapCache (improves performance by up to 15x the fps).

<Border.CacheMode>
    <BitmapCache />
</Border.CacheMode>

The problem is that i use a WrapPanel and a ValueConverter to dynamically resize and fit these containers into the WrapPanel so that they completely fill the space in either horizontal or tile views. Apparently, that doesn't work well with caching and it produces severe lags/stalls (frame drops to 0).

Currently my 3 options are:

  • Disable caching (and live with almost 15fps)
  • Disable resizing (looks unacceptable)
  • Disable caching and resizing only when resizing window (still performs bad but it's the best option i have)

My questions:

  • Why do i get these huge drops in performance while resizing with caching vs without caching?
  • Am i misusing caching or doing it wrong?
  • Is there a better way of fixing this mess without compromises?

Ok. After a lot of reading and experimenting, i figured two things:

  • First, Caching should not be used on elements that resize frequently, especially if they're too many (couldn't find out why). So, i basically cached fixed size child elements instead.

  • And that reminded me of Virtualization which was exactly what i was missing but didn't know was supported in WPF Lists .

With some more optimizations, now, i can resize the window buttery smooth.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM