title: How to bind two dependant ComboBoxes in a DataGrid
body: <p>I've a problem with the WPF datagrid. I have two ComboBox columns and the second one should set it's datacontext dependant of what is selected in the first one.</p>
  
  <p>ViewModel</p>
  
  <pre><code>public class MyCollection: AbstractViewModel
  {
      private BindingList&lt;string&gt; _subitems;
      public BindingList&lt;string&gt; Subitems
      {
          get { return _subitems; }
          set { _subitems = value; Notify("Subitems");}
      }
  
      private string _name;
      public string Name
      {
          get { return _name; }
          set { _name = value; Notify("Name");}
      }
  }
  </code></pre>
  
  <p>Xaml</p>
  
  <pre><code>&lt;DataGridTemplateColumn&gt;
      &lt;DataGridTemplateColumn.CellTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;TextBlock Text="{Binding SelectedName}" /&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellTemplate&gt;
      &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;ComboBox SelectedValuePath="Name"
                        x:Name="CollectionBox"
                        SelectedValue="{Binding SelectedName}"
                        DisplayMemberPath="Name"
                        ItemsSource="{Binding SomeBinding}"/&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
  &lt;/DataGridTemplateColumn&gt;
  &lt;DataGridTemplateColumn &gt;
      &lt;DataGridTemplateColumn.CellTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;TextBlock Text="{Binding SelectedSubitem}" /&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellTemplate&gt;
      &lt;DataGridTemplateColumn.CellEditingTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;ComboBox SelectedValue="{Binding SelectedSubitem}"
                        ItemsSource="{Binding ElementName=CollectionBox, Path=SelectedItem.Subitems}" /&gt;
          &lt;/DataTemplate&gt;
      &lt;/DataGridTemplateColumn.CellEditingTemplate&gt;
  &lt;/DataGridTemplateColumn&gt;
  </code></pre>
  
  <p>The binding for my first ComboBox is ok but I did not see any items in my second ComboBox (the viewmodel has entries for booth of the ComboBoxes); only the TextBox binding works as expected. I tryed it with a ComboBoxColumn as well but with the same result.</p>