Measuring the x,y distance between two elements in Silverlight
This is a useful thing to know if you ever want to do anything funky with Silverlight layout (for example, create an HtmlHost control that floats an iframe in exactly the right place over the plug-in):
Point point = element2.TransformToVisual(element1).Transform(new Point(0,0));
This returns a point that reflects the position (point) of element2 in element1's coordinate space. Nice.
Originally posted by Josh Twist on 5th of May 2009 here.