Mozy.com, an insurance policy for your hard drive.

Archive for the ‘Software’ Category

Fixing BindingList Deserialization

Tuesday, July 17th, 2007

I previously blogged about how to use the C# INotifyPropertyChanged interface with BindingList<T> instances so that your lists properly fire the ListChanged event with a ListChangedType of ItemChanged.

In that post, I also alluded to the fact that BindingList<T> is flawed with regard to serialization of BindingList<T> subtypes. The problem has to do with the fact that BindingList<T> listens for PropertyChanged events on any of its list items that implement INotifyPropertyChanged. However, because event handlers are not serializable, those listener connections are lost during the serialization process for subtypes, and they don’t get rewired when the list is deserialized. It’s straightforward to do that, but the implementation is missing from the .NET SDK, so we have to write it ourselves.

(more…)

Use INotifyPropertyChanged with BindingList

Tuesday, July 17th, 2007

After reading Bil Simser’s discussion on DataTable vs. BindingList<T>, I’m convinced that BindingList<T> is the way to go for representing domain objects in C#. However, effective use of BindingList does require a certain amount of planning and forethought on the part of the developer. There are a number of things you can do to increase your chances of success with BindingList, but this post is about having your list items implement INotifyPropertyChanged in order to propagate change events through the BindingList itself.

(more…)