I have two ObservableCollection objects and obj1 has attach to collection change event. Obj1 has a value from obj2 by obj1 = obj2. When I add any item on obj2 it execute collection changed event of object 1. I could not understand why this is happening.
public MainWindow() { InitializeComponent(); ObservableCollection<int> obj1 = new ObservableCollection<int>(); ObservableCollection<int> obj2 = new ObservableCollection<int>(); obj1 = obj2; obj1.CollectionChanged += new System.Collections.Specialized.NotifyCollectionChangedEventHandler(obj1_CollectionChanged); obj2.Add(1);
}
void obj1_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)
{
MessageBox.Show("Testing");
}