开发者_开发百科I have a silverlight control c1 that contains another silverlight control c2.
When trying to execute the below code.c1.c2.GetValue(Canvas.LeftProperty)
c1.c2.GetValue(Canvas.TopProperty)
The result is always 0. How can i get the Top and Left property for the inner control relative to the main canvas.
You can do the following:
var transform = c2.TransformToVisual(c1);
var relativePoint = transform.Transform(new Point(0, 0));
var c2left = c1.GetValue(Canvas.LeftProperty) + relativePoint.X
var c2top = c1.GetValue(Canvas.TopProperty) + relativePoint.Y
精彩评论