title: How do I bind a WPF control's content to its container's DataContext so I can apply a DataTemplateSelector based on that object?
body: <p>I'm trying to bind a WPF window atop a ViewModel that contains two collections, A and B. I'm attempting to use DataTemplates to display either A or B depending on the setting of a flag in my ViewModel.</p>
  
  <p>To that end, I've set the window's <code>DataContext = ViewModel</code>. However, when I attempt to bind a <code>ContentControl</code> to that DataContext and apply a <code>DataTemplateSelector</code> to it, the <code>item</code> parameter of the selector's <code>SelectTemplate(object item, DependencyObject container)</code> method is always null:</p>
  
  <pre><code>&lt;Window [snip] Title="MainWindow"&gt;
      &lt;Window.Resources&gt;
          &lt;!-- DataTemplate and Selector declarations --&gt;
      &lt;/Window.Resources&gt;
      &lt;Grid&gt;
          &lt;ContentControl Content="{Binding}"              
                          ContentTemplateSelector="{StaticResource templateSelector}" /&gt;
      &lt;/Grid&gt;    
  &lt;/Window&gt;
  </code></pre>
  
  <p>How should I be binding that <code>ContentControl</code> such that the Window's ViewModel will be passed through to its <code>DataTemplateSelector</code>?</p>