New ObservableCollection and adding elements to the loop

In terms of speed and number of generated notifications , this code:

ObservableCollection<Foo> foo = new ObservableCollection<Foo>(bar); this.SomeProperty = foo; 

same as:

 this.SomeProperty = new ObservableCollection<Foo>(); foreach (var v in bar) { this.SomeProperty.Add(v); } 

If they are the same, is it possible to somehow disable the generated notifications?

Goal: I'm trying to speed up the show of Telerik RadChart in silverlight. It seems to take some time to display (and freeze in the browser application) even after setting a property containing an ObservableCollection. Once the chart is drawn, everything works correctly.

+4
source share
1 answer

If freezing occurs before the actual binding is done, I would make sure that the delay is not really based on or due to other activity (for example, the time it takes to load the collection). Again, profiling is your friend.

+7
source

Source: https://habr.com/ru/post/1394204/


All Articles