Merging Two ObservableCollections
Solution 1
This is what worked for me:
Concat or Union, but the result is a IEnumerable, so it needs to be converted back into an ObservableCollection:
var result = new ObservableCollection<T>(list1.Concat(list2));
Solution 2
I found a reference to CompositeCollection on another SO article: Merged ObservableCollection
Since you're looking to do a Concat/Union, this seems to do exactly that. Too bad it's not strongly typed.
Solution 3
I went with volkerK's suggestion and then moved to:
http://msdn.microsoft.com/en-us/library/system.linq.enumerable.union.aspx Ta
DavidA
Updated on June 07, 2022Comments
-
DavidA about 2 years
I have two Observable Collections that I need to merge into one collection.
This arises because I have two methods, getTasks(staffID) which returns an ObservableCollection and getTasks(teamID) which selects the staff and pulls back the staff tasks.
For the teams I will have multiple small observableCollections, I just want to merge them.