开发者

WPF - Translate a point relative to MainWindow to it's coordinates relative to a child control

开发者 https://www.devze.com 2022-12-25 19:13 出处:网络
Is it possible to translate a point relative to MainWindow to be relative to one of its child controls?For example, sa开发者_StackOverflow社区y a control\'s upper left corner was located at 500, 500 r

Is it possible to translate a point relative to MainWindow to be relative to one of its child controls? For example, sa开发者_StackOverflow社区y a control's upper left corner was located at 500, 500 relative to MainWindow what code would convert that number to (0, 0)? I'd like the solution to be agnostic of the layout mechanism (i.e. not require me to parent the control in a Canvas and use the Top and Bottom methods).


See UIElement.TranslatePoint. For example:

var translatedPoint = mainWindow.TranslatePoint(new Point(500, 500), childControl)
0

精彩评论

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