I have a collection of data defined as follows (MyData
is defined as a class):
ObservableCollection<MyData> data = new ObservableCollection<MyData>();
I bind it with another function called another_func()
whenever the its data changes by:
data.CollectionChanged += data_CollectionChanged;
...
void data_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e)
{
another_func();
}
It worked well if I just add or remove elements from data
, i.e. it will call another_func()
automatically whenever these operations happen.
However, it didn't work (not trigger another_func()
) when I try to assign values to data
, for example:
data = another_data; // another_data also with type ObservableCollection<MyData>
Why can't this handle assignment event? And how to make it work?