1

So I have been dealing with a problem representing 10k+ rows in a listview (I might need pagination, but this is not about that), I had 2 problems:

  1. Item source loading took at least 10 seconds to load into the listview which made my UI hang
  2. Lag while focusing the listview

So I wanted to compare the same thing using a listbox than a datagrid. And I was amazed how the listbox reduced the loading time to almost nothing and also there is no lag.

Listview:

<ListView ItemsSource="{Binding SymbolContext}" BorderThickness="0">
    <ListView.ItemsPanel>
        <ItemsPanelTemplate>                                      
            <VirtualizingStackPanel />                                      
         </ItemsPanelTemplate>
    </ListView.ItemsPanel>
    <ListView.ItemTemplate>
        <DataTemplate>
            <TextBlock Text="{Binding Name}" />
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

ListBox:

<ListBox ItemsSource="{Binding SymbolContext}">
    <ListBox.ItemTemplate>
        <DataTemplate>                                       
            <TextBlock Text="{Binding Name}"></TextBlock>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

So my question is why did it take for the listview so much to represent the data and why did the listbox perform so well?

Norbert Forgacs
  • 605
  • 1
  • 8
  • 27
  • Have you used a profiler? Will surely show you why some code is slower or faster than another one. – MakePeaceGreatAgain Dec 05 '17 at 15:04
  • 2
    Please look at : https://stackoverflow.com/questions/4703641/what-is-the-difference-between-listbox-and-listview and https://stackoverflow.com/questions/227231/listbox-vs-listview-how-to-choose-for-data-binding – Sushant VS Dec 05 '17 at 15:06
  • 2
    I have read the 2 article but still there shouldn't be such a huge performance difference between the controls. – Norbert Forgacs Dec 05 '17 at 15:13

0 Answers0