My application has two lists
public ObservableCollection<StreamItemViewModel> SearchStreamItems { get; private set; }
public ObservableCollection<StreamItemViewModel> MyStreamItems { get; private set; }
And each are the DataSource of one ListBox. Each time I click the button more the applications load 100 new items, and after a few clicks it throws a OutOfMemoryException.
Is there a way to avoid the exception? Or what should I do? Stop loading more updates?
Instead of loading everything which is neither possible nor really desirable I would use a sliding window instead – when you reach a certain maximum list size (say i.e. 300 items) you automatically remove the top 100 items when you add the next 100 items to the bottom.
If you scroll just right after the update this shouldn’t even be noticeable by your users.