开发者

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 VirtualizationW开发者_StackOverflow社区rapPanels 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?


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.


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".


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜