Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get real Position of Window in WPF

Tags:

c#

wpf

how do I get the real Position (in Pixels) of a WPF-Window?

this.PointFromScreen( new Point( 0, 0 ) ); does not gives real Position on Screen when I use DPI of 150% for Font. I guess this has something to do with scaling, but in my case I need the "real" position on Screen.

like image 725
user1130329 Avatar asked Oct 01 '22 05:10

user1130329


1 Answers

I think you want PointToScreen. PointFromScreen converts screen coordinates into the coordinate system of the Visual.

var window = new Window();
Point screenCoordinates = window.PointToScreen(new Point(0,0)); 
like image 137
Tejas Sharma Avatar answered Oct 05 '22 10:10

Tejas Sharma