How to remove all the elements of the ObservableDataSource

Aug 16, 2012 at 9:45 AM

class Myclass{

     private ObservableDataSource<Point> dataSource = new ObservableDataSource<Point>();
     private System.Timers.Timer graphicalSpeedUpdater;

     public Myclass()
           graphicalSpeedUpdater = new System.Timers.Timer();
           graphicalSpeedUpdater.Elapsed += new ElapsedEventHandler(graphicalSpeedUpdaterOnTimedEvent);
           graphicalSpeedUpdater.Interval = 1000;
           graphicalSpeedUpdater.Enabled = true;
           plotter.AddLineGraph(dataSource, Colors.Green, 2, "Speed");

     private void graphicalSpeedUpdaterOnTimedEvent(object source, ElapsedEventArgs e)

         double x = graph_x++;
         double y = fileItemList[0].curSpeed_l;
         Point point = new Point(x, y);
         dataSource.AppendAsync(base.Dispatcher, point);

     private void resetChartButton_Click(object sender, RoutedEventArgs e)
         Here i want the current graph line shows absolute new data.... 
         To achieve this, one way i came up with is to clear all the points in dataSource and add new points into it so that the old graph shows the new information. but i was stuck since i can not find proper methods in dataSource, and i also tried :
         dataSource  = new ObservableDataSource<Point>();
But it doesn't work :(
         Anyone would be so kind to help me? THANKS!!!

Oct 2, 2012 at 9:44 AM
plotter.AddLineGraph returns a LineGraph hold to that (say data member g) then when you want to reset first remove the graph from the plotter 
like so: plotter.Children.Remove(g); now you can start new dataSource with dataSource = new ObservableDataSource<Point>();