On demand IEnumerable binding to ListBox

I have a potentially pretty large list of objects that I would like to bind to a ListBox in WPF. However, I would like the List to load in stages. How to associate a ListBox with an IEnumerable that loads itself on demand in such a way that the listbox only tries to list as many as it needs to be displayed?

+3
source share
3 answers

WPF ListBox uses VirtualizingStackPanel as a layout control for its items. You can set VirtualizingStackPanel to only load items as needed with the following XAML:

<ListBox VirtualizingStackPanel.IsVirtualizing="True" ItemSource="..." /> 
+3
source

You can save the list in a database - perhaps in memory - and then get the required fragment in your IEnumerable using LINQ.

+1
source

With winform, "virtual mode" - but AFAIK, is not the same in WPF. You could see this MSDN forum .

I basically agree with Drew Marsh - let the user filter the data, rather than view it.

0
source

All Articles