title: Binding Grid Height Using FindAncestor and AncestorLevel To Another Grid
body: <p>My question is about properly binding the property of one element to another.</p>
  
  <p>Here is the structure of my code:</p>
  
  <ol>
  <li><p>Data Template contains a grid (let's called the grid <code>GridA</code>), and in the grid, I specify an instance of a control, called <code>ControlA</code>.</p></li>
  <li><p><code>ControlA</code> is a <code>UserControl</code> that contains a <code>Grid</code>. There is custom logic in <code>ControlA</code> (code-behind) that dynamically builds the content - but in a nutshell, it uses another data template.</p></li>
  <li><p>The data template for <code>ControlA</code> consists of another <code>Grid</code>. I want to bind the <code>Height</code> property for this grid in this data template to the <code>Height</code> property of the <code>Grid</code> in the data template referenced in my first bullet point above (the grid called <code>GridA</code>).</p></li>
  </ol>
  
  <p>Here is the XAML that I have used for the binding, but, essentially, it isnt working, as its not finding the Grid:</p>
  
  <pre><code>&lt;Grid Height="{Binding Path=ActualHeight,
                         RelativeSource={RelativeSource FindAncestor,
                                         AncestorType=Grid,
                                         AncestorLevel=2},
                         UpdateSourceTrigger=PropertyChanged}"&gt;
  &lt;/Grid&gt;
  </code></pre>
  
  <p>I understand that by specifying <code>AncestorLevel=2</code>, that it will use the second "found" occurrence of the type that you are looking for, in this case, the type is <code>Grid</code>.  So in my mind, it will first find the <code>Grid</code> in <code>ControlA</code>, then it will continue to walk up the tree and find the <code>Grid</code> in the first data template, which is the <code>Grid</code> named <code>GridA</code>.  This should be the second occurrence, correct?</p>