-1

I'm a beginner with wpf app building and entity framework.
I'm building my first wpf app, I found out I should have replaced my auto-generated ICollection with ObservableCollection.
The problem is that I already did most of my code so far but am having some issues with INotifyPropertyChanged. I see all the codes about INotifyPropertyChanged use ObservableCollection.

Is it bad if I go to my auto-generated code now and replace the ICollection with ObservableCollection? Will it mess up my app?

colinD
  • 1,641
  • 1
  • 20
  • 22
mia
  • 1
  • 2

1 Answers1

-1

ObservableCollection is only useful if you want to add items to a collection at some point, and have a UI control automatically update to display the added / deleted items. ObservableCollection also has potential threading issues - any change to the collection must be done on the same thread as it was created on.

It has nothing to do with reflecting changes to properties of individual elements within the collection - that is what INotifyPropertyChanged is for.

Peregrine
  • 4,287
  • 3
  • 17
  • 34
  • Thank you! I am building a CRUD app so i will be constantly updating inserting and deleting items. My issue is i see lots of people used ObservableCollection and now i dont know if its safe to change my iCollection to ObservableCollection. Thank you for your feedback! – mia May 21 '20 at 09:53
  • This is why you shouldn't just blindly copy code you find online. Take time to study each class used and what functionality it provides - does it actually match with the problem you're trying to solve. – Peregrine May 21 '20 at 09:56