开发者

Listbox Data Virtualization and Multi-select

开发者 https://www.devze.com 2023-04-08 02:39 出处:网络
I have a listbox that can potentially have a large number of items with backing data. In order to handle data virtualization, I have tied into WPF\'s UI virtualization by writing a collection that imp

I have a listbox that can potentially have a large number of items with backing data. In order to handle data virtualization, I have tied into WPF's UI virtualization by writing a collection that implements the same interfaces as ObservableCollection an开发者_开发知识库d can spin up our backing data as needed.

This works fine. The problem comes when I introduce multi-select with the listbox. Because listbox manages selected items by object rather than index (SelectedItems), selecting all of the items causes all of the backing data to be spun up and held in memory by the listbox, defeating the data virtualization...

Is there a way to prevent this from happening other than re-writing ListBox to manage selection by index instead of object?

Thanks!

Eric


Why don't you use the Virtualizing option on the UI control? This will only load the data that is to be displayed on the screen.

http://www.kirupa.com/net/ui_virtualization_pg1.htm


We were using UI virtualization to control our data virtualization, but were having problems with listbox holding onto selection, so our data was not being unloaded.

What I ended up doing was tieing into the item generator for the virtualizing stack panel and listening to the data context changed event for the generated containers. When this happened, I either unloaded the real data from our wrapper.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号