The event you're looking for is CollectionChanged
.
A source of confusion for you (and others who try to do the same thing) is that you're thinking that when the collection changes, the source of your data grid has changed. Not so. The ItemsSource
of the data grid is still the collection - you haven't assigned it to a different collection, or cleared it. So PropertyChanged
and DataContextChanged
are not being raised, and handling them has no effect here.
Note that CollectionChanged
is pretty involved, because a lot of things constitute changes to a collection, so you're going to need to understand it pretty thoroughly to handle it correctly. I suspect that you don't really need to handle it - that you're trying to do something with events that can better be done through binding.