Reputation: 225
I have an ObservableCollection which is manipulated by a couple of classes. I want to find out which class fired the event. I already looked at the sender object and went through the properties of the NotifyCollectionChangedEventArgs but did not find anything. I only get the reason for the event such as: Reset, Add or Remove. What I am looking for is the originator.
private void OnCollectionChanged(object sender, NotifyCollectionChangedEventArgs e){
// if coming from one class do something
// else if coming from another class do something else
}
The purpose of this is that I need my collection to behave in a different way depending on the class that modified it.
Upvotes: 1
Views: 135
Reputation: 1219
That's impossible. If you really need to do that, you can change the type of objects you put in the collection to add some sort of "owner" property, indicating who created them.
Upvotes: 2