protected virtual void OnRemoveEventHooks(T item) { INotifyBusy busy = item as INotifyBusy; if (busy != null) { busy.BusyChanged -= new BusyChangedEventHandler(busy_BusyChanged); } INotifyUnhandledAsyncException unhandled = item as INotifyUnhandledAsyncException; if (unhandled != null) { unhandled.UnhandledAsyncException -= new EventHandler <ErrorEventArgs>(unhandled_UnhandledAsyncException); } INotifyPropertyChanged c = item as INotifyPropertyChanged; if (c != null) { c.PropertyChanged -= new PropertyChangedEventHandler(Child_PropertyChanged); } //IBindingList list = item as IBindingList; //if(list!=null) // list.ListChanged -= new ListChangedEventHandler(Child_ListChanged); INotifyChildChanged child = item as INotifyChildChanged; if (child != null) { child.ChildChanged -= new EventHandler <ChildChangedEventArgs>(Child_Changed); } }
protected virtual void OnAddEventHooks(T item) { INotifyBusy busy = item as INotifyBusy; if (busy != null) { busy.BusyChanged += new BusyChangedEventHandler(busy_BusyChanged); } INotifyUnhandledAsyncException unhandled = item as INotifyUnhandledAsyncException; if (unhandled != null) { unhandled.UnhandledAsyncException += new EventHandler <ErrorEventArgs>(unhandled_UnhandledAsyncException); } INotifyPropertyChanged c = item as INotifyPropertyChanged; if (c != null) { c.PropertyChanged += Child_PropertyChanged; } INotifyChildChanged child = item as INotifyChildChanged; if (child != null) { child.ChildChanged += Child_Changed; } }