Why is it better (in WPF, C#, Entity Framework) to bind ListBox to an ObservableCollection created upon the ObjectSet (from Entity Framework) rather than binding to ObjectSet directly?
One more question:
When I bind ListBox to ObservableCollection, any additions to the collection updates ListBox. Great. But ObservableCollection was created upon ObjectContext (in Entity Framework) and adding a new item to the collection doesn’t add the item to the context… how to solve this????
ObservableCollection implements
INotifyPropertyChangedas well asINotifyCollectionChanged, both of which WPF uses to rebind elements to the UI. Thus, you could add an item to the ObservableCollection and immediately the UI would update with no code interaction from you.ObjectSetimplements neither, and so doesnt get this functionality.