开发者

How to find the location of control on some upper level control?

How can i find the location of the 'SomeRectangle' ?

This Rectangle is the location and the size that i need to crop from t开发者_开发知识库he 'somepicture' that is actually the picture that appear in the background of the main grid.

    <Rectangle x:Name="SomeRectangle" Height="50" Width="50" Stroke="Red" HorizontalAlignment="Center" VerticalAlignment="Center" MinWidth="5" MinHeight="5" />


GeneralTransform gt = 
    SomeRectangle.TransformToVisual(Application.Current.RootVisual as UIElement);
Point offset = gt.Transform(new Point(0, 0));
double controlTop = offset.Y;
double controlLeft = offset.X;

Source: Silverlight Forum

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜