title: Is it possible to bind to a property on the container of the Adorned Element?
body: <p>In my WPF app we are using an adorner for displaying validation messages, in the particular case there is a single row grid that has multiple controls some of which have validation. The problem I'm having is that I want to force the width of the error message control to be the same as the grid but can't seem to find a way to reference that grid from the adorner template. Here is a sample of what I tried:</p>
  
  <pre><code>&lt;ControlTemplate x:Key="Local_TopAdornedTemplateWide"&gt;
      &lt;StackPanel&gt;
          &lt;AdornedElementPlaceholder x:Name="adornedElement"/&gt;
          &lt;TextBlock MaxWidth="{Binding Path=ActualWidth, RelativeSource={RelativeSource FindAncestor, AncestorType=Grid}, ElementName=adornedElement}"
                     TextWrapping="Wrap"
                     Text="{Binding Converter={StaticResource Local_ValidationErrorMessageConverter}}" 
                     Style="{DynamicResource Error_Text}" 
                     Padding="2 1 0 0" 
                     Visibility="{Binding ElementName=adornedElement, Mode=OneWay, Path=AdornedElement.IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
                     /&gt;
      &lt;/StackPanel&gt;
  &lt;/ControlTemplate&gt;
  </code></pre>
  
  <p>This causes the application to crash with an XamlParseException.</p>
  
  <p>Ideally the solution would not be specific to a grid so that it would get the width of any container type, but for now grid is the only use case.</p>
  
  <p><strong>Edit:</strong>
  Here is an example of another template we use in the application; this template would not work for my case as it would limit the error to be the width of a single column of the aforementioned grid:</p>
  
  <pre><code> &lt;ControlTemplate x:Key="Local_TopAdornedErrorTemplate"&gt;
          &lt;StackPanel&gt;
              &lt;AdornedElementPlaceholder x:Name="adornedElement"/&gt;
              &lt;TextBlock MaxWidth="{Binding ElementName=adornedElement, Path=ActualWidth}"
                         TextWrapping="Wrap"
                         Text="{Binding Converter={StaticResource Local_ValidationErrorMessageConverter}}" 
                         Style="{DynamicResource Error_Text}" 
                         Padding="2 1 0 0" 
                         Visibility="{Binding ElementName=adornedElement, Mode=OneWay, Path=AdornedElement.IsVisible, Converter={StaticResource BooleanToVisibilityConverter}}"
                         /&gt;
          &lt;/StackPanel&gt;
      &lt;/ControlTemplate&gt;
  </code></pre>
  
  <p>Using snoop I captured the following two screenshots (I could not take one of the full stack to prevent posting anything proprietary)</p>
  
  <p>This shot shows the grid I mentioned previously, within this it is the FinancialTextBox item that is being adorned </p>
  
  <p><img src="https://i.stack.imgur.com/nEqRd.png" alt="Adorned item"></p>
  
  <p>This shot shows two things, the item selected in blue is the highest ancestor of the grid in the previous shot, the yellow highlight is the Textbox from the content template</p>
  
  <p><img src="https://i.stack.imgur.com/sbnDf.png" alt="Adorner"></p>
  
  <p>With those two it seems to be apparent that (based on information from Contango's answer) the two items aren't not in the same visual tree which would lead me to believe my question is not possible. However the second template I added (which does work) points that at least some visual information from the adorned element lives on in the place holder. </p>
  
  <p>So now my question boils down to a) does this information include the parent of the adorned element and b) how can this be accessed via a binding on a different element?</p>