Silverlight - Convert List to ObservableCollection
In Silverlight, you will bind the controls such as List/Grid with Observable collection so that any change in the collection automatically reflected on the control.
Often you will be required to convert the List to an observable collection but there isn't exist any method which automatically do so in Silverlight. Moreover, WCF service can only return IEnumerable collection which you may want to convert to the ObservableCollection. So, here is generic way to convert any List to Observable collection;
| var observableCollection = new ObservableCollection<T>(); |
| foreach (var
item in enumerableList) |
| observableCollection.Add(item); |
| return observableCollection; |
I hope this will help you ... Cheers:)