WPF control location in window?

Is there a way to get the current rendered location of a WPF control after all current RenderTransform have been applied? I may just be blind, but I don't see the obvious method.

+6
c # wpf
source share
1 answer

I guess I should have continued to push out before asking ... but instead of deleting, maybe this will help someone later.

The trick is to convert the point (0,0) from the control axes to the axes of the window, so ...

Point renderedLocation = theControl.TranslatePoint(new Point(0,0), theWindow);

If you need an interior point on the control, it works the same way, just use this local point instead of (0,0).

Do not try to use it Margin or Padding , it does not work correctly.

+17
source share

All Articles