4

My listBox:

<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, but with VirtualizingStackPanel. If i change WrapPanel with VirtualizingStackPanel, items are showing only in a row while before i had many rows. I need help.

user2618311
  • 161
  • 2
  • 8

1 Answers1

-1

You need to set your ItemsPanelTemplate to a VirtualStackPanel, and set the Orientation to Vertical.

<ListBox.ItemsPanel>
    <ItemsPanelTemplate>
        <VirtualizingStackPanel Orientation="Vertical" 
                                IsVirtualizing="True" VirtualizationMode="Recycling" />
    </ItemsPanelTemplate>
</ListBox.ItemsPanel>
Jason Tyler
  • 1,331
  • 13
  • 26