0
我正在构建一个WPF数据可视化工具,其中的齿轮版本为LiveCharts。 我有一个名为SectionsCollection
的SectionsCollection对象,我需要在数据更改时重新加载。在重新分配到SectionsCollection
之前,我运行以下代码段。为WPF清除截图LiveCharts中的集合
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类型也是如此。