void UnsubscribeFromPropertyChangeNotifications(object instance) { INotifyPropertyChanged objectWithEvent = instance as INotifyPropertyChanged; if (objectWithEvent != null) { objectWithEvent.PropertyChanged -= SelectionPropertyChanged; } IPropertyGridHost supportsHost = instance as IPropertyGridHost; if (supportsHost != null) { supportsHost.PropertyGrid = null; } }
void SubscribeToPropertyChangeNotifications(object instance) { INotifyPropertyChanged objectWithEvent = instance as INotifyPropertyChanged; if (objectWithEvent != null) { objectWithEvent.PropertyChanged += this.SelectionPropertyChanged; } IPropertyGridHost supportsHost = instance as IPropertyGridHost; if (supportsHost != null) { supportsHost.PropertyGrid = this; } }