Why the need to create observable collection
i am watching this tutorial. at around 15:40, the speaker said something like a LINQ query won't create a rich collection like BindingListCollectionView
. i am thinking maybe 开发者_开发问答it means changes wont be saved to the database or something. so i tried replacing
var result = database.Customers.Execute(System.Data.Objects.MergeOption.AppendOnly);
with
var result = from cust in database.Customers
where cust.City == "Seattle"
select cust;
and all still works fine.
ObservableCollection have an event that is fired when their contents changed so a ListView, ComboBox, etc can stay in sync with your data when it changes. If the contents of the list will never change then having an ObservableCollection is not necessary.
Sometimes you can't use an ObservableCollection as you have custom collection classes already written that you want to bind to. In this situation you can implement the ICollectionChanged and IPropertyChanged interfaces on your custom collection.
Your custom collection will then work like an ObservableCollection (or at least to the extent of implementation in your collection).
精彩评论