title: How to retrieve Parent Visual Size within XamlCompositionBrushBase?
body: <p>I'm creating a class inheriting from <a href="https://docs.microsoft.com/en-us/uwp/api/windows.ui.xaml.media.xamlcompositionbrushbase" rel="nofollow noreferrer">XamlCompositionBrushBase</a> and want to know the <strong>render size of the visual</strong> the brush is attached to when it's hooked up in <code>OnConnected</code>.</p>
  
  <p>I need this info to create a surface in my composition that's the size of my visual in order to not only have the right pixel density, but also map from the visual's coordinates into the surface's space.  </p>
  
  <blockquote>
    <p>i.e. if I have a coordinate <em>50, 75</em>, I need to know the width/height of the visual to map the surface location to that location on the visual.</p>
  </blockquote>
  
  <p>Since the brush is a dependency object, I tried using <code>var parent = VisualTreeHelper.GetParent(this);</code> but that threw an exception:</p>
  
  <blockquote>
    <p>System.Exception occurred    HResult=0x8000FFFF<br>
    Message=Catastrophic failure (Exception from HRESULT: 0x8000FFFF
    (E_UNEXPECTED))<br>
    Source=</p>
  </blockquote>
  
  <p><em>Is this possible without using an attached property on the parent UIElement?</em></p>
  
  <p>Thanks</p>