private static void CreateBinding(IOnPropertyChanged sourceObj, string path, string propToNotify) { var pcdo = new PropertyChangeDependencyObject(); var binding = new Binding(path) { Source = sourceObj }; BindingOperations.SetBinding(pcdo, PropertyChangeDependencyObject.PropertyChangeDependencyProperty, binding); pcdo.DependentPropertyChanged += () => sourceObj.OnPropertyChanged(propToNotify); pcdos.Add(pcdo); }
public static void MonitorCollectionChanged(IOnPropertyChanged obj, string prop, Action callback) { var pcdo = new PropertyChangeDependencyObject(); var binding = new Binding(prop) { Source = obj }; BindingOperations.SetBinding(pcdo, PropertyChangeDependencyObject.CollectionChangeDependencyProperty, binding); pcdo.DependentCollectionChanged += () => callback(); pcdos.Add(pcdo); }