0

In my C# WPF application i have a List of objects with about 900000 entries.

I want to display these entries in a List View. Therefor i create a new window like this:

    System.Windows.Window myWin = new System.Windows.Window();
    myWin.Content = new myResult();
    myWin.Title = "Result";
    myWin.Show();

The list is stored in the ViewModel. The XAML looks like:

        <ListView
            x:Name="myListView"
            ItemsSource="{Binding ListSummary}"
            >

            <ListView.View>
...

During the line myWin.Show() the program freezes and shows following exception:

Ein Ausnahmefehler des Typs "System.OutOfMemoryException" ist in PresentationCore.dll aufgetreten.

Is there a limitation in entries for the listview? I know 900000 entries seems to be very much but this is the common amount of entries in my business case.

Julian
  • 185
  • 1
  • 15
  • Apparently you don't have enough memory to handle that many items. Make sure that you haven't disabled the UI virtualization. – mm8 Aug 17 '17 at 13:07
  • May be there are more than one issues. Take a look here: https://stackoverflow.com/questions/5326904/finding-the-true-memory-footprint-of-a-windows-application/5407911#5407911 – Sebastian Siemens Aug 17 '17 at 13:09
  • 1
    Maybe it's time to start paging / hierarchical data / ["don't show the whole list" technique here]. No matter what those 900000 items are, a user will never ever actually need to look into all of them during a single program run (supposed the program doesn't run forever without restart) so your best bet is to understand what the user will be actually searching for when he starts scrolling through this ridiculously huge list of items. – grek40 Aug 17 '17 at 13:16
  • Another thought: make sure that your list is not nested in some infinite size container like Scrollviewer or Stackpanel. Otherwise the list will try to expand to display all items, not taking advantage of virtualization. – grek40 Aug 18 '17 at 22:06

2 Answers2

0

Thanks for all your answers. I used this manual to build a proper virtualization. This works for me.

Julian
  • 185
  • 1
  • 15
-1

Not a full answer, but you'll want to start by looking into how to virtualize the ListView.

This is a promising start:

How to enable UI virtualization in Standard WPF ListView

Curt Toppin
  • 19
  • 1
  • 5