Search code examples
c#wpfrendertransform

Is UIElement.RenderTransform used by TransformToAncestor?


When a TransformToAncestor is called what Matrices are used to build up the resultant GeneralTransform? When step into the pdb all I see is a TransformField with a signature like:

private static readonly UncommonField<Transform> TransformField = new UncommonField<Transform>();

being used in the resultant GeneralTransform


Solution

  • Nothing beats Reflector. Especially while it's still free ;)

    The code is hairy enough but can be followed. Basically it walks up the visual tree and groups the transforms but the entire thing is much more complicated and I never really had an interest to dig that deep into it. Look into Visual.TrySimpleTransformToAncestor for the gory details.

    To answer the question, UIElement is never used explicitly of course; the transform is retrieved through an Effect (the UncommonField you mentioned), so I'm guessing that transforms in general are applied as effects, hence you can get them through this shortcut from anywhere, but that's just infrastructure and implementation details and I'm most likely wrong :)