static void OnDataSourcePropertyChanged(BindableObject bindable, object oldValue, object newValue) { SerialChart chart = bindable as SerialChart; DetachOldDataSourceCollectionChangedListener(chart, oldValue); AttachDataSourceCollectionChangedListener(chart, newValue); chart.NotifyDataSourceChanges(); }
static void OnColorPropertyChanged(BindableObject bindable, object oldValue, object newValue) { SerialChart chart = bindable as SerialChart; chart.NotifyColorChanges(); }
static void AttachDataSourceCollectionChangedListener(SerialChart chart, object dataSource) { if (dataSource != null && dataSource is INotifyCollectionChanged) (dataSource as INotifyCollectionChanged).CollectionChanged += new NotifyCollectionChangedEventHandler(chart.OnDataSourceCollectionChanged); }
static void DetachOldDataSourceCollectionChangedListener(SerialChart chart, object dataSource) { if (dataSource != null && dataSource is INotifyCollectionChanged) (dataSource as INotifyCollectionChanged).CollectionChanged -= chart.OnDataSourceCollectionChanged; }