Search code examples
wpfxamllayoutvirtualization

WPF arrange items in a grid with virtualization


I'm looking for way to present equally sized elements in a fixed number of rows and any number of columns. (Think of iTunes' or Picasa's album view. I believe some platforms refer to this as a 'gridview')

A WrapPanel would do the job, but I'm binding against a very large collection of objects, so I need virtualization.

I've been looking around the web, and found both commercially available VirtualizationWrapPanels and blog posts on how to implement your own VirtualizationPanel, but I can't seem to find any simpler solutions.

Is it possible to arrange virtualized databound items in a grid-style view (fixed number of rows) with standard WPF components?


Solution

  • It is the responsibility of the Panel to provide Virtualization. Unfortunately the framework only provides a virtualizing StackPanel:

    http://msdn.microsoft.com/en-us/library/system.windows.controls.virtualizingpanel.aspx

    There is a very good blog post that provides a virtualizing WrapPanel here:

    https://blogs.claritycon.com/custom-panels-in-silverlight-wpf-part-4-virtualization-7f3bded02587

    Another alternative is to use a DataGrid, this will virtualize for you.