title: Why is the binding data context set to the control's data context?
body: <p>I have a user control called "CardDisplay", with an exposed Dependency Property called "CardValue". The control itself is basically just a textblock (an image really, but it works with a textblock and is easier to show) bound to this property, like so:</p>
  
  <pre><code>&lt;UserControl&gt;
     &lt;Grid&gt;
        &lt;TextBlock Text="{Binding CardValue}"/&gt;
     &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>The data context is set to <code>this</code> in the code-behind for simplicity, though it works with a standard view model as well. This works fine, if you use it like this:</p>
  
  <pre><code>&lt;local:CardDisplay CardValue="2"/&gt;
  </code></pre>
  
  <p>"2" appears in the control as expected. However, if I change that line to</p>
  
  <pre><code>&lt;local:CardDisplay CardValue="{Binding CurrentCard}"/&gt;
  </code></pre>
  
  <p>Nothing is displayed, and I get a binding exception saying that "CurrentCard" could not be found on type "DisplayCard". Obviously it shouldn't be looking at display card, it should be looking at the parent's data context (which of course, has a property called "CurrentCard").</p>
  
  <p>Switching to an "ElementName" binding works as expected:</p>
  
  <pre><code>&lt;TextBock x:Name="HiddenText" Text="{Binding CurrentCard}"/&gt;
  &lt;local:CardDisplay CardValue="{Binding Path=Text, ElementName=HiddenText}"/&gt;
  </code></pre>
  
  <p>Basically, I am at a loss as to why my binding suddenly stops looking in the right spot. The same behavior can be seen in a simple data template as well:</p>
  
  <pre><code>&lt;DataTemplate x:Key="CardTemplate"&gt;
      &lt;Image Source="{Binding Converter={StaticResource IntToImgSourceConverter}"/&gt;
  &lt;/DataTemplate&gt;
  
  &lt;ContentPresenter ContentTemplate="{StaticResource CardTemplate}" Content="{Binding CurrentCard}"/&gt;
  </code></pre>
  
  <p>Will throw a binding exception saying it can't find a property called "CurrentCard" on the "int" type.</p>
  
  <p>Why are the parent-level bindings trying to find properties on the child's data context? Removing the data context from the child fixes (bindings work as expected again), but it seems like that shouldn't be necessary.</p>
  
  <p>EDIT:
  To be clear, binding the DP is basically useless after setting the data context because of this. If my bindings are correct, what is the best way to get it to use the parent's data context? The use case I am thinking of is getting this to work:</p>
  
  <pre><code>&lt;ItemsControl ItemsSource={Binding PlayerHand}&gt;
     &lt;ItemsControl.ItemTemplate&gt;
         &lt;DataTemplate&gt;
            &lt;local:CardDisplay CardValue="{Binding Path=CardValue}"/&gt;
         &lt;/DataTemplate&gt;
     &lt;/ItemsControl.ItemTemplate&gt;
  &lt;/ItemsControl&gt;
  </code></pre>