title: ListBox ItemsSource WPF Binding
body: <p>I'm not understanding something about binding. I have a <code>DataTemplate</code> for type Object which is working, but in there I want to make another <code>ListBox</code> and set the data to that of one of the properties of an Object. I've been using Snoop to look at the data context and the data context of the <code>ListBox</code> in the Object <code>DataTemplate</code> is an Object, but there is an error with the <code>ItemsSource</code> and I don't know why. I'm doing <code>ItemsSource={Binding componentList, Mode=TwoWay}</code> and an Object has a componentList and componentList is an <code>ObservableList</code>. What am I missing?</p>
  
  <p>Here's my XAML code:</p>
  
  <pre><code>&lt;Window.Resources&gt;
  
  &lt;DataTemplate DataType="{x:Type properties:Component}"&gt;
    &lt;StackPanel&gt;
      &lt;TextBlock Text="TEST COMPONENT" /&gt;
      &lt;ListBox DataContext="{Binding propertyList}" ItemsSource="{Binding propertyList}" /&gt;
    &lt;/StackPanel&gt;
  &lt;/DataTemplate&gt;
  
  &lt;DataTemplate DataType="{x:Type properties:Object}"&gt;
    &lt;StackPanel&gt;
      &lt;TextBlock Text="TEST OBJECT" /&gt;
      &lt;ListBox ItemsSource="{Binding componentList, Mode=TwoWay}" /&gt;
    &lt;/StackPanel&gt;
  &lt;/DataTemplate&gt;
  
  &lt;/Window.Resources&gt;
  </code></pre>
  
  <p>And my C# code:</p>
  
  <pre><code>public class Component
  {
    public string name;
    public ObservableCollection&lt;IProperty&gt; propertyList;
  }
  
  public class Object
  {
    public UnsignedProperty objectID;
    public ObservableCollection&lt;Component&gt; componentList;
  }
  </code></pre>
  
  <p>I make a <code>ListBox</code> in code and set it's <code>ItemsSource</code> to a list of Objects and that's seeing my Object <code>DataTemplate</code>, but that's where it stops</p>
  
  <pre><code>ListBox properties = new ListBox();
  ObservableCollection&lt;Properties.Object&gt; t = new ObservableCollection&lt;Properties.Object&gt;();
  t.Add(selectedObject); //potentially more objects
  properties.ItemsSource = t;
  PropertyPane.Content = properties;
  </code></pre>
  
  <p>any help would be much appreciated. Thanks!</p>