问题
In august 2012, this article was published http://msdn.microsoft.com/en-us/library/windowsphone/develop/hh286406%28v=vs.92%29.aspx which talks about database best practices.
In this article, is mentioned that data virtualization in listbox must be enabled and suggests to follow an article dated August 2010.
" For more information about enabling data virtualization on data-bound ListBox controls, see Improving ListBox Performance in Silverlight for Windows Phone 7: Data Virtualization"
However I thought that listbox virtualization is enabled by default with what was released in Mango version. Is that correct? Is a listbox databinded to an observable collection virtualized by default?
回答1:
The Ui is virtualised by default - so the list box reuses datatemplates for the list items, and only renders those list items which are actually scrolled into view.
However, if you are using observablecollection, then the data is not virtualised.
So if you have a list of 1,000,000 items, then all of them will be in memory, but only the ui for a few of them will be created and drawn.
To virtualise the data as well, you'll need to implement a custom ilist, possibly also supporting inotifycollectionchanged. This implementation might, for example, use SQLite to just load data items as they are needed by scrolling.
来源:https://stackoverflow.com/questions/12608628/is-listbox-virtualized-by-default-in-wp7-mango