How to remove or hide comments on an OxyPlot graph? I am doing this but it does not work:
public void AddAnnotation(IEnumerable<Annotation> annotations)
{
foreach (var annotation in annotations)
{
MyOxyPlotModel.Annotations.Add(annotation);
}
RefreshAxisSeriesPlot();
}
public void RemoveAnnotation(IEnumerable<Annotation> annotations)
{
foreach (var annotation in annotations)
{
MyOxyPlotModel.Annotations.Remove(annotation);
}
RefreshAxisSeriesPlot();
}
private void RefreshAxisSeriesPlot() => MyOxyPlotModel.InvalidatePlot(true);
With this code, adding annotations works, but removing annotations does not work.
Edit:
OK, I found the problem in my code.
In fact, I had not completed the evaluation of my LINQ query from which I get my IEnumerable<Annotation> annotations
… And it recreates a new Annotation
object at each iteration of IEnumerable<Annotation> annotations
.