How to get the coordinates of the window?

Warning: count(): Parameter must be an array or an object that implements Countable in /home/styllloz/public_html/qa-theme/donut-theme/qa-donut-layer.php on line 274
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 | 15 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