Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Screen coordinates of a control on a design surface #52

Open
MillerMark opened this issue Dec 1, 2022 · 5 comments
Open

Screen coordinates of a control on a design surface #52

MillerMark opened this issue Dec 1, 2022 · 5 comments

Comments

@MillerMark
Copy link

How can I find the screen coordinates of a selected control on a XAML design surface?

@mgoertz-msft
Copy link
Member

Hi @MillerMark

You should be able to get the ViewItem from the selected ModelItem.View and from there use the SelectionFrameBounds and PointToScreen to get the screen coordinates.

I hope this helps.

@MillerMark
Copy link
Author

MillerMark commented Dec 8, 2022

PointToScreen seems to return points relative to the ViewItem's immediate parent (IOW, no change to the point), so I'm still looking for a way to translate the points derived from SelectionFrameBounds into screen coordinates.

@mgoertz-msft
Copy link
Member

Could be a bug in the designer's extensibility layer. Looping in @chabiss whose team owns the designer.

@MillerMark
Copy link
Author

Any new suggestions on how I can determine screen coordinates?

@MillerMark
Copy link
Author

Update - I've found a hack using reflection to calculate screen coordinates of a control on a XAML design surface. Let me know if there's a more officially-sanctioned way to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants