Reputation: 475
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.
Upvotes: 7
Views: 14971
Reputation: 2181
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));
Upvotes: 9
Reputation: 11932
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.
Upvotes: 5
Reputation: 475
I went with volkerK's suggestion and then moved to:
http://msdn.microsoft.com/en-us/library/system.linq.enumerable.union.aspx Ta
Upvotes: 0