0

I have a listview that contains a list of 'rows', which in term, contains a list of 'columns'. For now, I use List for both rows and columns (i.e. I have a List and it the Rows objet, I have a List, but as the number gets bigger, the time it takes to update the GUI and overall performance of the program gets pretty bad. Plus, the GUI isn't notified when the items (columns within the rows) change, so I have to do an Item.Refresh, which seems to refresh the whole thing each time, adding to the slow performance

Is there any other type of object that I could use to accelerate the whole thing. Meaning it would need to satisfied the following points : - Faster that List - When I add a new rows, the listview is updated. Is possible, only the new rows is added instead of the whole listview. - When I change a Columns object, the GUI is updated. If possible, only the modified columns objet is affected so the whole Listview is not changed.

Note that there are quite a number of actual calculations behind the scene for displaying the columns object. I have currently working on optimizing this end, but I'm pretty sure using a better collection would help quite a lot here.

Thanks

David Brunelle
  • 6,528
  • 11
  • 64
  • 104

1 Answers1

2

I believe what you are looking for is an Observable Collection

This collection type will fire a CollectionChanged event when items are added. You will not need to refresh the collection because WPF controls support this out of the box.

Note

The CollectionChanged event will not be fired when indiviual elements are updated. If you want these updates to show on the UI, the object within the collection should implement INotifyPropertyChanged

Community
  • 1
  • 1
Nick Freeman
  • 1,411
  • 1
  • 12
  • 25
  • 2
    Also, if you find yourself adding many rows at once, you might consider a RangeEnabledObservableCollection. See: http://stackoverflow.com/questions/8606994/adding-a-range-of-values-to-an-observablecollection-efficiently – cunningdave Mar 27 '13 at 19:48
  • In this particular case, once the items have been added, I will not need to add any new rows so this should do the job. – David Brunelle Mar 28 '13 at 12:42
  • I tried using an ObservableCollection in which the content implement InotifyPropertyChanged interface as mentionned in the link, but nothing happens in my GUI. Does anything have to be done to the the UI element to allow the changed ? – David Brunelle Apr 03 '13 at 19:36
  • nothing happens in the GUI when you add elements or when you edit elements? – Nick Freeman Apr 03 '13 at 20:13