Return a list as IEnumerable, but enable PropertyChange notification
in my Silverlight 4 app, I have a class which contains a list of objects. As I want to bind this list to a listbox and notify the listbox about changes to the list, I use an ObservableCollection<>. I know want to control the adding and deleting of the items in the ObservableCollection 开发者_StackOverflowby returning an IEnumerable<> and Add/Remove methods in my class.
But now there is no automatic change notification for the listbox to which the list is bound. How can I achieve the automatic notification of the listbox, when my list is returned as IEnumerable (or any other type that would suit the needs)
Thanks in advance,
FrankYour class should implement the INotifyCollectionChanged interface, since you're implementing the Add and Remove methods in your class, you can raise the notification events.
There is a list for this: ReadOnlyObservableCollection<>
精彩评论