问题
I am developing an universal app and using a ListView
to display more than 50000 entries. I am using the following method to load the data:
- In the assets folder there's a simple utf-8 txt file with all the items (headwords of a dictionary in alphabetical order just to be precise).
I load the file into an
IList
withReadLinesAsync
:IList<string> lista1 = await FileIO.ReadLinesAsync(listafile1);
Finally I set the ItemsSource of the ListView to this IList:
listView1.ItemsSource = lista1;
It seems to be fast and work fine but at the end of the list the items are disappearing after scrolling. I experience this on phones and pc and even in the emulator too. I made a video of it to be more clear.
I already created the same app for android and ios and didn't experience this type of error.
I would appreciate any help
István
回答1:
The solution is to add a VirtualizingStackPanel to ListView in xaml:
<ListView>
<ListView.ItemsPanel>
<ItemsPanelTemplate>
<VirtualizingStackPanel/>
</ItemsPanelTemplate>
</ListView.ItemsPanel>
</ListView>
来源:https://stackoverflow.com/questions/25039561/windows-store-universal-app-listview-oddity