Answer the question
In order to leave comments, you need to log in
How to get window coordinates?
Found a similar question , but none of the answers worked for me.
1) this.Left
and this.Top
- the studio writes that these are not numbers (I believe that ∞)
2) throws an error: System.InvalidOperationException: "This Visual element is not connected to PresentationSource." PS If it matters, then my Window has the following properties:PointToScreen(new Point(this.Left, this.Top))
AllowsTransparency="true" Background="Transparent" WindowStyle="None"
Answer the question
In order to leave comments, you need to log in
As it turned out, you really need to call the Show() function and then everything will work (thanks to Alexey Pavlov for the tip)
Now I have the following code:
public MainWindow()
{
InitializeComponent();
this.Show();
// PointToScreen работает корректно
var a = PointToScreen(new Point(Left, Top)).ToString();
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question