-
- Nir Hasson
- Posts: 71
- Joined:
- Contact:
Dynamic data collection performance
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 ?
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
- Posts: 71
- Joined:
- Contact:
Re: Dynamic data collection performance
Just a quick update:
I changed the implementation to use the Visibility property in order to show/hide items and performance is much better..
I changed the implementation to use the Visibility property in order to show/hide items and performance is much better..
-
-
sfernandez
Site Admin
- Posts: 3197
- Joined:
Re: Dynamic data collection performance
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.
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: Ahrefs [Bot], Baidu [Spider], Google [Bot] and 3 guests