Silverlight Binding Lesson

I learned a very important lesson about binding in Silverlight that I thought I would share. 

Here is what I was trying to do:

<TextBlock Text=”{Binding Path=MyPeople, Converter={StaticResource OldestPersonNameConverter}}” />

MyPeople is a collection of People and the converter is going to take that collection, find the oldest person and return their name.  I thought this would just work and it does the first time.  However in this case, adding a new person to MyPeople will NOT trigger the binding to update, your converter will never run again.

Right? Wrong?  I’ve been debating the point with a few people at Objectsharp, and I didn’t expect this to fail (some did).  I was under the assumption that binding was binding, the magic behind the covers would look for INotifyPropertyChanged or INotifyCollectionChanged regardless of the property you are trying to bind.

This doesn’t work for my example, but in my actual code I was able to bind to myCollection.Count which will fire a PropertyChanged event when you add or remove an item from the collection.  In the actual example above, I don’t have a good answer, they all have drawbacks.