Ejemplo n.º 1
0
        protected override void UpdateItems()
        {
            if (Plotter != null)
            {
                foreach (var m in Markers)
                {
                    Plotter.MainCanvas.Children.Remove(m);
                }
                Markers.Clear();

                if (ItemsSource != null && ItemsSource.GetEnumerator().MoveNext())
                {
                    foreach (var p in ItemsSource)
                    {
                        var visualItem = this.ItemTemplate.LoadContent() as FrameworkElement;
                        visualItem.DataContext = p;
                        //Set the binding again to make it attach immediately
                        visualItem.SetBinding(LineGraphWithPoints.XValueProperty, visualItem.GetBindingExpression(LineGraphWithPoints.XValueProperty).ParentBinding);
                        visualItem.SetBinding(LineGraphWithPoints.YValueProperty, visualItem.GetBindingExpression(LineGraphWithPoints.YValueProperty).ParentBinding);

                        Markers.Add(visualItem);
                    }

                    var es = new Microsoft.Research.DynamicDataDisplay.DataSources.EnumerableDataSource <DependencyObject>(Markers);
                    es.SetXMapping(p => LineGraphWithPoints.GetXValue(p as DependencyObject) + GetXValue(this));
                    es.SetYMapping(p => LineGraphWithPoints.GetYValue(p as DependencyObject));
                    DataSource = es;


                    if (Viewport != null & Markers.Count > 1)
                    {
                        ((ChartPlotter)Viewport.Plotter).FitToView();
                    }
                }
            }
        }
    protected override void UpdateItems()
    {
      if ( Plotter != null)
      {
        foreach (var m in Markers)
          Plotter.MainCanvas.Children.Remove(m);
        Markers.Clear();

        if (ItemsSource != null && ItemsSource.GetEnumerator().MoveNext())
        {
          foreach (var p in ItemsSource)
          {
            var visualItem = this.ItemTemplate.LoadContent() as FrameworkElement;
            visualItem.DataContext = p;
            //Set the binding again to make it attach immediately
            visualItem.SetBinding(LineGraphWithPoints.XValueProperty, visualItem.GetBindingExpression(LineGraphWithPoints.XValueProperty).ParentBinding);
            visualItem.SetBinding(LineGraphWithPoints.YValueProperty, visualItem.GetBindingExpression(LineGraphWithPoints.YValueProperty).ParentBinding);

            Markers.Add(visualItem);
          }

          var es = new Microsoft.Research.DynamicDataDisplay.DataSources.EnumerableDataSource<DependencyObject>(Markers);
          es.SetXMapping(p => LineGraphWithPoints.GetXValue(p as DependencyObject) + GetXValue(this));
          es.SetYMapping(p => LineGraphWithPoints.GetYValue(p as DependencyObject));
          DataSource = es;


          if (Viewport != null & Markers.Count > 1)
          {
            ((ChartPlotter)Viewport.Plotter).FitToView();
          }
        }
      }
    }