I'm having trouble getting a UserControl's position on a canvas in Silverlight. Usually, I'd use this code to get the position of an object and it works fine:
GeneralTransform gt = this.TransformToVisual(Application.Current.RootVisual as UIElement);
Point offset = gt.Transform(new Point(0, 0));
double controlTop = offset.Y;
double controlLeft = offset.X;
I have a UserControl that has a method which translates its position. When I try and get the new position using the above code, it only returns the initial position the object started at. Is there a way of getting the new position for a UserControl that is programmatically added to the main canvas? I've tried putting this code in the mainpage as well as in the UserControl itself (and exposing it via a method).