Teie kommentaarid

Ah. I missed setting selectable to false for series.

Doing this 

foreach (var s in plotView.Model.Series)
{
s.Selectable = false;
}

Also resolved the issue.

Just some remarks on this


I was running into this error  this with Xamarin.Android OxyPlot 1.0

The plot is being redrawn / invalidated at 40Hz. This is working fine with SyncRoot. 

But I discovered that when I tap on the plot, I get the "Collection was modified; enumeration operation may not execute" exception. Interesting because I had disabled all touch interactions but looks like OxyPlot still try and process the touch and do something with the collection

foreach (var a in plotView.Model.Axes)
{
    a.IsPanEnabled = false;
    a.IsZoomEnabled = false;
    a.Selectable = false;
}

plotView.FocusableInTouchMode = false;
plotView.Focusable = false;
plotView.FocusedByDefault = false;
plotView.LongClickable = false;
plotView.Clickable = false;

The problematic code that was causing the exception was

if (bubbleSeries.Points.Count == 0)
{
    bubbleSeries.Points.Add(new ScatterPoint(xAxisValue, yAxisValue));
}
else
{
    bubbleSeries.Points[0] = new ScatterPoint(xAxisValue, yAxisValue);
}

model.Background = isWithinAccelTolerence ? OxyColors.LightGreen : OxyColors.LightSalmon;

appActivity.RunOnUiThread(() =>
{
    lock (model.SyncRoot)
    {
        model.InvalidatePlot(false);
    }
});

Fixed by moving points collection to inside SyncRoot area. 

appActivity.RunOnUiThread(() =>
{
lock (model.SyncRoot)
{
if (bubbleSeries.Points.Count == 0)
{
bubbleSeries.Points.Add(new ScatterPoint(xAxisValue, yAxisValue));
}
else
{
bubbleSeries.Points[0] = new ScatterPoint(xAxisValue, yAxisValue);
}

model.Background = isWithinAccelTolerence ? OxyColors.LightGreen : OxyColors.LightSalmon;

model.InvalidatePlot(false);
}
});

My guess is that the touch interaction on the plot view somehow interacted with the Points collection in the background, and of course updating the plot at 40Hz made this problem pretty obvious.