sbaeumlisberger/VirtualizingWrapPanel

VirtualizingWrapPanel does not virtualize

Closed this issue · 3 comments

Describe your issue
The wrappanel loads all items at once

<ScrollViewer>
            <ItemsControl ItemsSource="{Binding Items}" 
                          ScrollViewer.CanContentScroll="True"
                               VirtualizingPanel.CacheLengthUnit="Item" 
                               VirtualizingPanel.ScrollUnit="Item" 
                               VirtualizingPanel.VirtualizationMode="Recycling"
                               VirtualizingPanel.IsVirtualizingWhenGrouping="True">
                <ItemsControl.ItemsPanel>
                    <ItemsPanelTemplate>
                        <controls:VirtualizingWrapPanel Orientation="Vertical"
                                                        VirtualizingPanel.CacheLength="40"
                                                        VirtualizingPanel.IsContainerVirtualizable="True"
                                                        VirtualizingPanel.IsVirtualizingWhenGrouping="True"
                                                        VirtualizingPanel.IsVirtualizing="True"
                                                        VirtualizingPanel.VirtualizationMode="Recycling"/>
                    </ItemsPanelTemplate>
                </ItemsControl.ItemsPanel>
                <ItemsControl.ItemTemplate>
                    <DataTemplate>
                        <local:MintingPreview_Control Data="{Binding Data}"/>
                    </DataTemplate>
                </ItemsControl.ItemTemplate>
            </ItemsControl>
        </ScrollViewer>

you can see some duplicate properties as I was trying around. no matter what I try, All memory gets instaltly occupied.
Version Info
Package Version [e.g. 1.5.2]
.NET Version: [e.g. .NET Framework 4.7.2]
OS Version: [e.g. Windows 10 Build 19041.508]

The problem is that the items control is wrapped inside a ScrollViewer. That breaks the virtualisation, because the scrolling can not be handled by the VirtualzingWrapPanel. To solve your issue remove the ScrollViewer and make sure that the ItemsContol height ist not infinite.

Also keep in mind that the default CacheLengthUnit is Page. That means when you set the CacheLength to 40, 40 times more items than visible are cached (realized).

Thank you, i managed to use the listView from the sample application. This works.
There seem to be some bugs (probably misuse from my side)

But at least it initiates correctly and doesnt take 30 seconds to load 2 gb into ram.

the last issue that Im facing is that the memory constantly goes up. for example when I scroll a couple of lines down, the memory increases (expected)

When I scroll these lines up again, The memory increases further. So, either the elements are not recycled properly or the resources are not released properly.

i started to set the settings manually.
I think it was the recycling setting (i changed too many settings at once :P)

The issue is resolved. Thank you.