2

In my application I have big canvas with a lot of items. It is a mix of Rectangles and custom usercontrols. The items are added dynamically in codebehind and the UI looks a bit like this:

Simplified UI of canvas

When I load more than 100 items it starts go run slow, and it feels like UI Virtualization is the way to go here.

I read about the Virtual Canvas mentioned in this blog post, and are thinking about trying it out. But since this is written 8 years ago I am not sure if this is the right way to go or if anyone knows a better solution. Should I use something else than a Canvas maybe?

Zeno
  • 581
  • 1
  • 7
  • 23
  • I remember I was investigating the same topic long time ago. I remember having a collection of links to some works similar to that VirtualizingCanvas. If you search for VirtualizingCanvas you should be able to find 2 or 3 different implementations. I don't remember which's the best. Also, [ZoomableCanvas](https://blogs.msdn.microsoft.com/kaelr/2010/08/11/zoomableapplication2-a-million-items/) which handles virtualization for both zoom&scroll operations in 2D (not just 1D) and I believe it was build upon original VirtCanvas works. If I find my notes, I'll paste links here, but .. chance is low – quetzalcoatl Jul 17 '16 at 20:22
  • 1
    Also, I just accidentally found: [this article on the subject](http://blog.devart.com/wpf-smooth-scrolling-with-ui-virtualization.html) aside from the explanations, there is a "download the source code" there that says you can use it freely. Their approach with approximate scrolling seems interesting. Then, finally, you may find [this one](http://www.jonathanantoine.com/2011/10/07/wpf-4-5-%E2%80%93-part-11-new-features-for-the-virtualizingpanel/) simply an interesting read. – quetzalcoatl Jul 17 '16 at 20:26
  • BTW. slowdowns at just 100 items sounds .. bad. You should easily be able to reach much more. There's probably some issues with your item's layout. Too complex (meaning: too many nested controls) or non-contant item heights that force WPF to recalculate it too often? You may want to see some hints on various topics [here on MSDN](https://msdn.microsoft.com/en-us/library/aa970683(v=vs.110).aspx) and [this](http://badecho.com/2010/07/efficient-representation-of-large-data-sets-with-itemscontrol-2/) - although I had not read it all, it seems to cover many important parts of getting it work. – quetzalcoatl Jul 17 '16 at 20:39

0 Answers0