Let, I have an ObservableCollection
. I m binding it's Count property with the Text property of a TextBlock
. As one or more items added or deleted from the collection the Count get updated. As I know ObservableCollection
implements both the INotifyPropertyChanged
and INotifyCollectionChanged
, so when the Count property is changed then my view should be updated. I am expecting the TextBlock
that is bind with the Count property should show the updated count. But anyhow NotifyPropertyChange
is not being called for the Count property!
Here how I am binding the Text property with Count:
<TextBlock Text="{Binding MyObservableCollection.Count}" />
Is there any way to notify property change for the Count property of an ObservableCollection
?
As For as I know
ObservableCollection
will update automatically in the cases of Add/Remove if you are Set a new value for entireObservableCollection
means you need to Raise theObservableCollection
in the setter of the property. So if you are setting new collection means addPropertyChangedEvent
and if you are doing add/remove means don't need to Raise the property.If you are in second scenario Check your output window for Binding errors most probably that will be your problem.