【发布时间】:2020-03-18 07:45:39
【问题描述】:
如何删除或隐藏OxyPlot 图表上的 cmets?我正在这样做,但它不起作用:
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);
使用此代码,添加注释有效,但删除注释不起作用。
编辑:
好的,我在代码中发现了问题。
事实上,我还没有完成对我的 LINQ 查询的评估,我从中得到了我的 IEnumerable<Annotation> annotations... 它在 IEnumerable<Annotation> annotations 的每次迭代中重新创建一个新的 Annotation 对象。
【问题讨论】:
-
如何比较注释?完全相同的 Annotation 可以是内存中的不同对象。