title: WPF (mvvm) databinding itemssource and selecteditem to different models
body: <p>I've got a WPF databinding issue that I'm not getting past. I have an MVVM setup like the following:</p>
  
  <pre><code>public class ModelA
  {
      public int Id
      {
          //Property uses INotifyPropertyChanged
      }
  }
  
  public class ModelB
  {
      public ModelA The_A
      {
          //Property uses INotifyPropertyChanged
      }
  }
  
  public class ViewModel
  {
      public IEnumerable&lt;ModelA&gt; ModelAList
      {
          //Property uses INotifyPropertyChanged
      }
  
      public IEnumerable&lt;ModelB&gt; ModelBList
      {
          //Property uses INotifyPropertyChanged
      }
  }
  </code></pre>
  
  <p>My XAML's DataContext is ViewModel (surprise), and I've got this ListBox in it:</p>
  
  <pre><code>&lt;ListBox ItemsSource="{Binding ModelBList}"&gt;
      &lt;ListBox.ItemTemplate&gt;
          &lt;DataTemplate&gt;
              &lt;ComboBox
                  ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}, Path=DataContext.ModelAList"
                  SelectedItem="{Binding The_A}"/&gt;
          &lt;/DataTemplate&gt;
      &lt;/ListBox.ItemTemplate&gt;
  &lt;/ListBox&gt;
  </code></pre>
  
  <p>When I open my window, the ComboBox does not have an item selected, yet if I select something from the checkbox, The_A gets set to whatever I selected.</p>
  
  <p>My guess is that the ModelA's in my ModelAList are different from the ModelA's in the ModelB's. Is there a way I can make this databinding work? Perhaps I'm missing something obvious or I'm not attacking the problem correctly.</p>
  
  <p>Thanks much!</p>