title: How to bind WPF TreeView to a List<Drink> programmatically?
body: <p>So I am very new to WPF and trying to bind or assign a list of Drink values to a wpf treeview, but don't know how to do that, and find it really hard to find anything online that just shows stuff without using xaml.</p>
  
  <pre><code>struct Drink
  {
      public string Name { get; private set; }
      public int Popularity { get; private set; }
  
      public Drink ( string name, int popularity )
          : this ( )
      {
          this.Name = name;
          this.Popularity = popularity;
      }
  }
  
  List&lt;Drink&gt; coldDrinks = new List&lt;Drink&gt; ( ){
      new Drink ( "Water", 1 ),
      new Drink ( "Fanta", 2 ),
      new Drink ( "Sprite", 3 ),
      new Drink ( "Coke", 4 ),
      new Drink ( "Milk", 5 ) };
          }
      }
  </code></pre>
  
  <p>How can I do this in code? For example:</p>
  
  <pre><code>treeview1.DataItems = coldDrinks;
  </code></pre>
  
  <p>and everything shows up in the treeview.</p>