title: DataTemplate with Border needs to change Background based on parent control
body: <p>The border of a datatemplate inside a control needs to change its background brush depending on situation.</p>
  
  <p>Since my code is at work and I am home trying to recall the structure, apology for pseudo coding.</p>
  
  <p>It looks something like:</p>
  
  <pre><code>&lt;parent control&gt;
  
   &lt;custom:controlwithdatatemplate needs Border background to be green/&gt;
  
   &lt;custom:controlwithdatatemplate needs Border background to be red/&gt;
  
  &lt;/parent conrol&gt;
  </code></pre>
  
  <p>In the datatemplate:</p>
  
  <pre><code>&lt;dataTemplate&gt;
  
   &lt;Border Background="{Binding RelativeSource, findancestor x:Type Border??}"
  
  &lt;/dataTemplate&gt;
  </code></pre>
  
  <p>So my guess is set the binding condition of border dynamic (maybe find ancestor of Border Type). But Since Setting the Border style at parent control might not piped down to the datatemplate of child xaml, I am not sure if this is correct approach.  Is exposing brush as dependency property the only way?  Can I somehow provide two different resource or style at the parent xaml and each datatemplate of the control to bind to differnt resource/style in the parent xaml?  </p>
  
  <p>-----------EDIT-------------------</p>
  
  <p>Although I was looking for another way than using dependency property, I still chose the answer from threads below since it resolves the above issue and can't think of any better way for now.</p>