I'm creating a class inheriting from XamlCompositionBrushBase and want to know the render size of the visual the brush is attached to when it's hooked up in OnConnected
.
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.
i.e. if I have a coordinate 50, 75, I need to know the width/height of the visual to map the surface location to that location on the visual.
Since the brush is a dependency object, I tried using var parent = VisualTreeHelper.GetParent(this);
but that threw an exception:
System.Exception occurred HResult=0x8000FFFF
Message=Catastrophic failure (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))
Source=
Is this possible without using an attached property on the parent UIElement?
Thanks