I'm trying out MVVM in VB.Net for a while now and started out with some of my entities using List(of T)s, which I xml serialized to disk. Now, I updated the classes used by the Lists to implement INotifyPropertyChanged so I also changed the List(of T)s to ObservableCollection(of T)s.
After which, the XML serializer stopped working :'( A colleague told me that ObservableCollections, unlike generic Lists, are not serializable.
If so then how can I make them Serializable? Thanks in Advance~! 😀
Best Answer
Your college is half correct.
ObservableCollection(Of T)
is indeed serializable but it is so through the binary serializer, not the XML one.What you can do to work around this to wrap the serialization of any collections of
ObservableCollection(Of T)
withList(Of T)
. Just do the conversion at the point of serialization.For example ...