ListBox WPF-VirtualizingStackPanel with two lines, e.g. wrappanel

My Box List:

<ListBox VirtualizingStackPanel.IsVirtualizing="True" VirtualizingStackPanel.VirtualizationMode="Recycling" Name="lst" ScrollViewer.HorizontalScrollBarVisibility="Disabled" ScrollViewer.VerticalScrollBarVisibility="Visible" Margin="0,0,0,-23">
...
<ListBox.ItemsPanel>
<ItemsPanelTemplate>
          <WrapPanel/>
    </ItemsPanelTemplate>
</ListBox.ItemsPanel>

I need the same thing, but with VirtualizingStackPanel. If I change the WrapPanel with VirtualizingStackPanel, the elements are displayed only in the line, and before I had many lines. I need help.

+4
source share
1 answer

You need to install ItemsPanelTemplatein VirtualStackPaneland install Orientationon Vertical.

<ListBox.ItemsPanel>
    <ItemsPanelTemplate>
        <VirtualizingStackPanel Orientation="Vertical" 
                                IsVirtualizing="True" VirtualizationMode="Recycling" />
    </ItemsPanelTemplate>
</ListBox.ItemsPanel>
-1
source

All Articles