title: How would you bind a DataTrigger to a Child property from a resource-defined Style?
body: <p>How can I style an element based on changes in child properties? I would accept a different approach, but the desired result is simply that the parent property is set a certain way as long as a a child property (IsPressed) is true.</p>
  
  <p>If we are styling one named item with an in-line style we can simply identify our child using ElementName, but we can even be less specific and use Child.IsPressed:</p>
  
  <pre><code>&lt;Border Name="parentBorder" Padding="20"&gt;
      &lt;Button Name="childButton" Content="Don't Push Me Bro"/&gt;
      &lt;Border.Style&gt;
          &lt;!--Now how can I do this from a static resource where I don't know the elementname?--&gt;
          &lt;Style TargetType="Border"&gt;
              &lt;Style.Triggers&gt;
                  &lt;DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Child.IsPressed}" Value="True"&gt;
                       &lt;Setter Property="Background" Value="Blue"/&gt;
                  &lt;/DataTrigger&gt;
              &lt;/Style.Triggers&gt;
          &lt;/Style&gt;
      &lt;/Border.Style&gt;
  &lt;/Border&gt;
  </code></pre>
  
  <p>But since I want to reuse the style and style several Borders I would like to move it to a resource, which is identical, except of course we are making a presumption that Child will always be a Button:</p>
  
  <pre><code>&lt;Style x:Key="ButtonBorder" TargetType="{x:Type Border}"&gt;
      &lt;Style.Triggers&gt;                
          &lt;DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Child.IsPressed}" Value="True"&gt;
              &lt;Setter Property="Background" Value="Blue"/&gt;
          &lt;/DataTrigger&gt;
      &lt;/Style.Triggers&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>What is the best approach, or what am I missing? I can see that when "Child" is used as an inline style, intellisense colors Child differently and I'm sure that means something. Is assuming things about the type of Child from resource-defined styles just no good?</p>