我正在使用LiveCharts的 Geared 版本构建 WPF 数据可视化工具。我有一个名为 SectionsCollection 的对象SectionsCollection
,我需要在数据更改时重新加载它。在重新分配给SectionsCollection
.
try
{
if (SectionsCollection != null && SectionsCollection.Count > 0)
{
SectionsCollection.Clear();
}
}
catch(Exception e)
{
Status += "Error in clearing SectionsCollection.\n"+e;
}
SectionsCollection = new SectionsCollection();
以下错误SectionsCollection.Clear();
在线路上间歇性发生,标签为NullReferenceException 发生。
Exception thrown: 'System.NullReferenceException' in LiveCharts.Wpf.dll
Additional information: Object reference not set to an instance of an object.
如果我检查它SectionsCollection
不为空且不为空,为什么会出现此错误?
VisualsCollection 和 SeriesCollection 类型似乎也会出现此错误。