does anyone have a functioning virtualising WrapPanel I can use in a WPF application?
I have downloaded and tried the implementation at http://virtualwrappanel.codeplex.com/. However, I get the following exception:
"Layout measurement override of element 'MyNamespace.VirtualizingWrapPanel' should not return PositiveInfinity as its DesiredSize, even if Infinity is passed in as available size."
This is when trying to apply the wrappanel to a ListBox
That problem is probably occuring because you have your listbox inside another control, such as a stack panel or scroll viewer, which allows the listbox to grow to whatever size it likes. While the virtual wrap panel shouldn't give an error in this case, it does explain the performance problem.
Even using one of Microsoft's own virtualising panels won't fix the performance issues in this case because the virtualisation is defeated. Since the listbox can grow to whatever size it likes, it does so and draws all the items even if they're not on screen... hence the virtualisation doesn't apply.
If you ensure your listbox isn't inside one of these sorts of containers, you should find the virtualisation starts working performance improves significantly.
This is probably a bug that you might be able to fix yourself. Look for the
MeasureOverride
method. It always seem to return theavailableSize
wich was passed to the method. As the exception states you must not returnavailableSize
when it containsdouble.PositiveInfinity
. So try this:I haven't looked at the implementation in details. But who knows, you might be able to get a away with this if the panel doesn't save state between
MeasureOverride
andArrangeOverride
(wich it shouldn't if it is well implemented).