title: How to access elements from an ItemCollection?
body: <p>I want to access the contents of an <code>ItemCollection</code> that contains the items from a <code>Treeview</code> (called OOB).</p>
  
  <pre><code>if (OOB.Items.Count &gt; 0)
  {
      ItemCollection items = OOB.Items;
      foreach (TreeViewItem node in items)
  </code></pre>
  
  <p>The <code>foreach</code> throws the runtime error:</p>
  
  <blockquote>
    <p>Unable to cast object of type 'System.Xml.XmlElement' to type 'System.Windows.Controls.TreeViewItem'.</p>
  </blockquote>
  
  <p>I can SEE the information in the <code>ItemCollection</code> items that I want to access from the debugger:</p>
  
  <p><a href="https://i.stack.imgur.com/Xik4A.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Xik4A.jpg" alt="enter image description here"></a></p>
  
  <p>How can I access the elements, specifically the Element Name?</p>