Awesome q2a theme

How to get the coordinates of the window?

0 like 0 dislike
I found a similar question, but none of the answers I came up.

1)this.Left and this.Top Studio says that it is not the numbers (I suppose that ∞)

2) PointToScreen(new Point(this.Left, this.Top)) error: System.InvalidOperationException: "This Visual is not connected to a PresentationSource."

PS If it matters, the Window I have has the following properties:
AllowsTransparency="true" Background="Transparent" WindowStyle="None"
by | 26 views

1 Answer

0 like 0 dislike
As it turned out, really need to call the function Show() and then it will work (thanks to Alexey Pavlov for the tip)
Now I have such code:
public MainWindow() { InitializeComponent(); this.Show(); // PointToScreen works correctly var a = PointToScreen(new Point(Left, Top)).ToString(); }

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
5 answers
asked Mar 28, 2019 by segment
0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
110,608 questions
257,187 answers
40,796 users