-1

I'm kinda new to WPF and I am having a few issues with the performance of my application. The solution should be a VirtualizingWrapPanel. I made some research and there are not many tutorials or documentations that explain how to use it correctly. I downloaded an example project and built a DLL (https://github.com/sbaeumlisberger/VirtualizingWrapPanel). I then referenced this in my program and tried this code:

<vwp:VirtualizingItemsControl VirtualizingPanel.CacheLengthUnit="Item" VirtualizingPanel.ScrollUnit="Pixel" VirtualizingPanel.VirtualizationMode="Recycling">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <vwp:VirtualizingWrapPanel Orientation="Vertical" SpacingMode="None" StretchItems="False"/>
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
            
    <local:my_custom_control/>
    <local:my_custom_control/>
    <local:my_custom_control/>
    <local:my_custom_control/>
    <local:my_custom_control/>
    <local:my_custom_control/>
    ...

</vwp:VirtualizingItemsControl>

However, this code does not work and has exactly the same performance as a normal wrap panel. Does anyone know what the problem is? Im sorry if this sounds stupid or something like this, im kinda new to this stuff.

zKeviin
  • 37
  • 4
  • Purpose of vitrualized panel is to avoid to "show" elements that are not drawed in the visible area, after that ... there is a little marge to smooth it... when you scroll down element are drawed (i hope to not make an error with preterit) . Perhaps you should begin with the embedded virtualizin(stack)panel (if i remember well) to be sure of the effects on your application. After that you could know more easily if it's a ui problem, a code problem, or if problem come from the control (config) – Vonkel. May 23 '21 at 20:12
  • This is my program with a normal WrapPanel: https://youtu.be/v5D2diycLnM. As you can see the performance is AWFUL and as far as I know, virtualization should help A LOT. So my question is how to correctly use the VirtualizationWrapPanel? I tried the code from above but this is incorrect. – zKeviin May 23 '21 at 20:56

1 Answers1

2

After a lot of trying I got it. This is my code:

Xaml:

<vwp:VirtualizingItemsControl Name="vic" 
                               VirtualizingPanel.CacheLengthUnit="Item" 
                               VirtualizingPanel.ScrollUnit="Pixel" 
                               VirtualizingPanel.VirtualizationMode="Recycling"
                               VirtualizingPanel.IsVirtualizingWhenGrouping="True"
                               >
     <ItemsControl.ItemsPanel>
         <ItemsPanelTemplate>
             <vwp:VirtualizingWrapPanel Orientation="Vertical" SpacingMode="None" StretchItems="False" />
         </ItemsPanelTemplate>
     </ItemsControl.ItemsPanel>
 </vwp:VirtualizingItemsControl>

C#:

List<Button> buttons = new List<Button>();

list.add(new Button() { Content = "Name", Width = 90, Height = 40 });

vic.ItemsSource = buttons;
ICollectionView cv = CollectionViewSource.GetDefaultView(vic.ItemsSource);
zKeviin
  • 37
  • 4