Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting position/width/height of MainWindow [duplicate]

Tags:

wpf

I'm wondering about the best way to get information about the current position and width/height of the MainWindow. I want to keep a child window inside the main window so I want to check the coordinates of the MainWindows borders during the move function of the child window. I could only find the Window.LocationChanged event but it doesn't solve my problem in a satisfying way. Are there better options?

like image 502
Unfixable Avatar asked Mar 06 '12 08:03

Unfixable


2 Answers

You can access the position of the main window all over your code via Application.Current.MainWindow.Left and Application.Current.MainWindow.Top, respectively. Hope this will help.

like image 155
Dudemeister Avatar answered Oct 19 '22 07:10

Dudemeister


But, you should check "WindowState". In "Maximized" state properties "Left" and "Top" keep the values of the window in it's normal state. Window position in "Maximized" state discribes here: How can I find the position of a maximized window?

like image 30
no.Oby Avatar answered Oct 19 '22 08:10

no.Oby