3

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?

3 Answers 3

3

I've recently had to have a hunt round for similar functionality and struggled to find anything that was production ready.

I found a series of articles and sample code that contain a Virtualizing Tile Panel.

I've been using it and it has been fairly stable. There were some changes that needed to be made though. We had to add some of the keyboard control into the panel as it wasn't implemented, tabbing needed to be changed as well as adjusting tile sizes, etc. It's a good starting point if you decide to roll your own.

One major caveat though was that it also MUST have a parent that is constrained to a limited size else it errors out. This is not normally an issue as you will want it to be limited in size so you can enable scrolling. There may be a solution to this particular problem but we didn't have time to investigate.

1
  • Note that the code is no longer available to download (dead link in the article). Adaptations of that code can be found by searching "VirtualizingTilePanel" in your favorite search engine (I found two on GitHub and one on Code Project).
    – Arkane
    Jul 12, 2022 at 14:30
2

A quick-and-dirty solution is to use a list (in your case a horizontal one) of "grouping items" (in your case vertical ones) which will determine desired number of rows. Virtualization will occur on the "groupers".

2
  • What exactly do you mean by "grouping items"?
    – J D
    Mar 10, 2013 at 15:29
  • @JonHarrop Items which sole purpose is to present a group of other items.
    – Agent_L
    Mar 18, 2013 at 13:15
1

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.

1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.