Nir Hasson
Topic Author
Posts: 53
Joined: 10 Nov 2013, 21:20
Contact:

Dynamic data collection performance

13 Feb 2014, 23:55

I have an ItemsControl displaying set of data items using my own data template.
The ItemsControl uses data binding for its ItemsSource property.

Since not all available data items can be displayed at once I use a simple mechanism that updates the visible data collection from the source database. The implementation uses Noesis::Gui::Collection class for that purpose by simply clearing it and adding the relevant data items to display. The update interval is set to 5 seconds.

The problem is that I'm getting very noticeable performance hit each time the collection is getting update.
Am I missing something ? Is there better approach to achieve this goal ? Is there any workaround to increase performance ? (Maybe keeping up a static set of items and just update their data contexts ?
 
Nir Hasson
Topic Author
Posts: 53
Joined: 10 Nov 2013, 21:20
Contact:

Re: Dynamic data collection performance

14 Feb 2014, 09:48

Just a quick update:
I changed the implementation to use the Visibility property in order to show/hide items and performance is much better..
 
User avatar
sfernandez
Site Admin
Posts: 1918
Joined: 22 Dec 2011, 19:20

Re: Dynamic data collection performance

17 Feb 2014, 11:26

Hi Nir,

As you discovered it is better to use the Visibility property to show/hide items of an ItemsControl (or any part of the interface).

When clearing the items of the items collection you are destroying all the visual elements associated to each item template, and when adding new items you are creating all the item template elements again. These are heavy operations compared to a simple property update when modifying the Visibility of an item.

It is always better to hide unused elements than remove them from the UI tree, unless you have memory constraints and are loading and replacing big parts of the interface.

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 1 guest