开发者

How do I obtain the client coordinates where a Panel (Canvas, stackpanel, etc) is located in a WPF app?

I need to programatically obta开发者_StackOverflowin the client coordinates where a panel (stackpanel for instance) is located. When using the Windows API, a button has a TopLeft and BottomRight coordinate that determines its location within the window in which it resides. How do I obtain those coordinates for a stackpanel in a WPF window ?

Thank you for your help,

John.


You can call TransformToVisual() which gets a GeneralTransform relative to some other element for which you can use your container (frame/ window)

GeneralTransform gt = stackPanel1.TransformToVisual(parentWindow);         
Point p = gt.Transform(new Point(0, 0));
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜