title: Accessing WPF UserControl child element property
body: <p>Let's say I have a UserControl with several child controls</p>
  
  <pre><code>&lt;UserControl x:Class="Any.AnyControl"
      &lt;Grid&gt;
          &lt;Label Name="label1" Background="Black" /&gt;
          ... more controls here  
      &lt;/Grid&gt;
  &lt;/UserControl&gt;
  </code></pre>
  
  <p>and I use it in MainWindow like so:</p>
  
  <pre><code>&lt;Window&gt;
      &lt;Grid&gt;
           &lt;local:AnyControl/&gt;
           // I want to access AnyControl label1 Background property here 
      &lt;/Grid&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>I know how I can access AnyControl label1 Background property in code-behind, but is there any way I can access it in parent XAML?</p>
  
  <p>my code now:
  in parent XAML</p>
  
  <pre><code>&lt;local:AlertControl LabelBackground="Blue"&gt;                           
  </code></pre>
  
  <p>in UserControl</p>
  
  <pre><code>  &lt;Label Background="{Binding LabelBackground, RelativeSource={RelativeSource AncestorType=UserControl}}" /&gt;
  </code></pre>
  
  <p>and try with this too</p>
  
  <pre><code>&lt;Label Background="{Binding LabelBackground, RelativeSource={RelativeSource AncestorType=local:AlertControl}}" /&gt;
  </code></pre>