private static void DetachOldDataSourceCollectionChangedListener(SerialChart chart, object dataSource) { if (dataSource != null && dataSource is INotifyCollectionChanged) { (dataSource as INotifyCollectionChanged).CollectionChanged -= chart.OnDataSourceCollectionChanged; } }
private static void AttachDataSourceCollectionChangedListener(SerialChart chart, object dataSource) { if (dataSource != null && dataSource is INotifyCollectionChanged) { (dataSource as INotifyCollectionChanged).CollectionChanged += new NotifyCollectionChangedEventHandler(chart.OnDataSourceCollectionChanged); } }
private static void OnDataSourcePropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) { SerialChart chart = d as SerialChart; DetachOldDataSourceCollectionChangedListener(chart, e.OldValue); AttachDataSourceCollectionChangedListener(chart, e.NewValue); chart.ProcessData(); }