0

I saw a lot of topics with the problem:

"Object does not contain a definition for X and no extension method X accepting a first argument of type Object"

But none of them had the solution to my problem.

Situation: I want to save 3 series of DataPoints. Therefor i made a List that holds the series:

List<OxyPlot.Series.DataPointSeries> filesToBeStored;
    public OxyPlot.Series.DataPointSeries saveAnalyseBSITotal;
    public OxyPlot.Series.DataPointSeries saveAnalyseSBSI;
    public OxyPlot.Series.DataPointSeries saveAnalyseTBSI;

In the Form.cs I call the SaveFile(...):

        for (int i = 0; i < plotSBSIBandsA.Model.Series.Count; i++)
        {
            OxyPlot.Series.DataPointSeries sA = (plotSBSIBandsA.Model.Series[i] as OxyPlot.Series.DataPointSeries);
            OxyPlot.Series.DataPointSeries sB = (plotSBSIBandsB.Model.Series[i] as OxyPlot.Series.DataPointSeries);
            sB.Points.Clear();

            for (int j = 0; j < sA.Points.Count; j++)
            {
                sB.Points.Add(new OxyPlot.DataPoint(sA.Points[j].X, sA.Points[j].Y));
            }
        }
        if(saveButtonClicked)
            {this.SaveFile(sB)}

The complete Save-Class is:

 using System;
 using System.Collections.Generic;
 using System.Linq;
 using System.Text;

 namespace BSIAnalyzer
 {
     class SaveFile
     {

    List<OxyPlot.Series.DataPointSeries> filesToBeStored;
    public OxyPlot.Series.DataPointSeries saveAnalyseBSITotal;
    public OxyPlot.Series.DataPointSeries saveAnalyseSBSI;
    public OxyPlot.Series.DataPointSeries saveAnalyseTBSI;

    public SaveFile(OxyPlot.Series.DataPointSeries sA)
    {
        for (int i = 0; i < sA.Points.Count; i++)
        {
            saveAnalyseBSITotal.Points.Add(new OxyPlot.DataPoint(sA.Points[i].X, sA.Points[i].Y));
        }
    }

    public SaveFile(List<OxyPlot.Series.DataPointSeries> series)
         {
             filesToBeStored.Insert(0, saveAnalyseBSITotal);
             filesToBeStored.Insert(1, saveAnalyseSBSI);
             filesToBeStored.Insert(2, saveAnalyseTBSI);

             for (int k = 0; k < series.Count; k++)
             {
                 filesToBeStored[k].Points.Add(new OxyPlot.DataPoint(series[k].Points.X, series[k].Points.Y));
             }
         }
     }
 }

In the forloop with te "k" i got the error.

Levi Botelho
  • 24,626
  • 5
  • 61
  • 96
E. Verdi
  • 310
  • 2
  • 19
  • 1
    isn't Points an array? where series[k].Points.X would be wrong. needs something like series[k].Points[?].X – Marvin Smit Oct 24 '13 at 11:43
  • What is `X` in your case? – Alessandro D'Andria Oct 24 '13 at 11:46
  • What's the datatype of filesToBeStored? – gleng Oct 24 '13 at 12:02
  • Marvin thanks a lot. Now i read my own code again i see i forgot the place of the points. it should be: inline for (int k = 0; k < series.Count; k++) { for (int l = 0; l < series[k].Points.Count; l++) { filesToBeStored[k].Points.Add(new OxyPlot.DataPoint(series[k].Points[l].X, series[k].Points[l].Y)); } } – E. Verdi Oct 24 '13 at 12:36

0 Answers0