How to create an ObservableCollection using LINQ in Silverlight
- by sonofpirate
In a non-Silverlight world, it is easy to use LINQ to create an ObservableCollection. This is because the ObservableCollection class has constructors that accept any IEnumerable<T or List<T. However, the Silverlight version does not! This means that code such as:
var list = (from item in e.Result
select new ViewModel(item)).ToList();
Items = new System.Collections.ObjectModel.ObservableCollection<ViewModel>(list);
will not work in Silverlight.
Is there another option to make this work besides resorting to a for-each statement?