title: Binding a Combobox within a DataTemplate correctly in Wpf
body: <p>I am trying to bind the ComboBox below to the list of Characters in the ObservableCollection, but it wont show anything. Any ideas why?</p>
  
  <p>XAML:</p>
  
  <pre><code>    &lt;TabControl ItemsSource ="{Binding TextEditors}"
       &lt;TabControl.ContentTemplate&gt;
        &lt;DataTemplate&gt;
         &lt;ListBox&gt; ItemsSource="{Binding TextLines}"
          &lt;ListBox.ItemTemplate&gt;
           &lt;DataTemplate&gt;
            &lt;Grid&gt;
  
  
                 &lt;ComboBox 
                     ItemsSource="{Binding DataContext.InvCharacter, RelativeSource={RelativeSource AncestorType={x:Type TabItem}}}" 
                     DisplayMemberPath="name" 
                     SelectedValuePath="cid" 
                     SelectedValue="{Binding cid}"&gt;
                 &lt;/ComboBox&gt;
  
  
            &lt;/Grid&gt;
           &lt;/DataTemplate&gt;
          &lt;/ListBox.ItemTemplate&gt;
         &lt;/ListBox&gt;
        &lt;/DataTemplate&gt;
       &lt;/TabControl.ContentTemplate&gt;
      &lt;/TabControl&gt;
  </code></pre>
  
  <p>this is the class i am referring to:</p>
  
  <pre><code>     class TextEditorVM: IViewModel {
           public ObservableCollection&lt;TextLineVM&gt; TextLines { get { return textLines; } set { textLines = value;} }
           public ObservableCollection&lt;T_Character&gt; InvCharacters { get { return invCharacters; } set { invCharacters = value; } }
  
  
           public TextEditorVM(T_Dialogue dialogue)
           {
  
               DialogueManager.Instance.Register(this);
               this.TextLines = new ObservableCollection&lt;TextLineVM&gt;();
               this.InvCharacters = new ObservableCollection&lt;T_Character&gt;();
           }
      }
  </code></pre>
  
  <p>and the MainVM:</p>
  
  <pre><code>     class MainVM : IViewModel
       {
             public ObservableCollection&lt;TextEditorVM&gt; TextEditors { get { return textEditors; } set { textEditors = value; OnPropertyChanged("TextEditors"); } 
       }
  </code></pre>
  
  <p>my T_Character Class looks like this now : </p>
  
  <pre><code>    public class T_Character
      {
  
         public String cid { get; set; }
         public String name { get; set; }
  
         public T_Character(String cid, String name)
         {
            this.cid = cid;
            this.name = name;
         }
      }
  </code></pre>