The fact that it is a LINQ result might perhaps not be relevant for the question, but I\'m mentioning it anyway - since this is the context which has resulted in this questi
Just use:
ObservableCollection x = new ObservableCollection(enumerable);
That will do the required copying. There's no way of observing changes to the live query - although the idea of an ObservableQuery
is an interesting (though challenging) one.
If you want an extension method to do this, it's simple:
public static ObservableCollection ToObservableCollection
(this IEnumerable source)
{
if (source == null)
{
throw new ArgumentNullException("source");
}
return new ObservableCollection(source);
}