title: Clearing SectionsCollection in LiveCharts for WPF
body: <p>I'm building a WPF data visualization tool with the Geared version of <strong>LiveCharts</strong>.
  I have a SectionsCollection object named <code>SectionsCollection</code> that I need to reload as the data changes. I run the following code segment before reassigning to <code>SectionsCollection</code>.</p>
  
  <pre><code>        try
          {
              if (SectionsCollection != null &amp;&amp; SectionsCollection.Count &gt; 0)
              {
                  SectionsCollection.Clear();
              }
          }
          catch(Exception e)
          {
              Status += "Error in clearing SectionsCollection.\n"+e;
          }
          SectionsCollection = new SectionsCollection();
  </code></pre>
  
  <p>The following error occurs intermittently on the <code>SectionsCollection.Clear();</code> line, with the label <strong>NullReferenceException occurred</strong>.</p>
  
  <pre><code>Exception thrown: 'System.NullReferenceException' in LiveCharts.Wpf.dll
  
  Additional information: Object reference not set to an instance of an object.
  </code></pre>
  
  <p>If I check that <code>SectionsCollection</code> is not null and is not empty, why is this error coming up?</p>
  
  <p>This error seems to occur for VisualsCollection and SeriesCollection types as well.</p>