internal void BindData() { if (this.DataPoints.Count > 0) { this.DataPoints.Clear(); } if (this.DataSource != null) { if (this.DataSource is IEnumerable) { IEnumerable itemsSource = this.DataSource as IEnumerable; foreach (object item in itemsSource) { DataPoint dp = new DataPoint(); dp.DataContext = item; if (DataMappings != null) { try { dp.BindData(item, DataMappings); } catch { throw new Exception("Error While Mapping Data: Please Verify that you are mapping the Data Correctly"); } } this.DataPoints.Add(dp); } } } }
private void DataSource_CollectionChanged(object sender, NotifyCollectionChangedEventArgs e) { if (e.Action == NotifyCollectionChangedAction.Reset) { BindData(); return; } if (e.OldItems != null) { var removedDataPoints = (from dp in DataPoints where dp.DataContext != null && e.OldItems.Contains(dp.DataContext) select dp).ToList(); foreach (DataPoint dp in removedDataPoints) { dp.DetachEventFromWeakEventListner(); DataPoints.Remove(dp); } } if (e.NewItems != null) { foreach (object item in e.NewItems) { DataPoint dp = new DataPoint(); dp.DataContext = item; if (DataMappings != null) { try { dp.BindData(item, DataMappings); } catch { throw new Exception("Error While Mapping Data: Please Verify that you are mapping the Data Correctly"); } } //this.DataPoints.Add(dp); DataPoints.Insert(e.NewStartingIndex, dp); } } if(Chart != null && Chart._toolTip != null) Chart._toolTip.Hide(); }