Reputation: 36048
I think there is a bug with the Window.Width and Window.Height of wpf. I need my window to cover my entire desktop (there are two monitors) but first let me show you why I think there is a bug.
I don't know if you guys know AutoIt but it is a nice program to automate simple stuff. so if I want to resize my MainWindow to cover all the space in my first monitor (same thing as if I where maximizing a window) I will execute this method on autoit:
and when I execute that code my window that I am creating in visual studio extends and it appears exactly as if it where to be maximized.
so far the coordinates seem to be working.
now when I do the same thing with c# on wpf:
public static void setWindowSize(System.Windows.Window w)
{
w.Left = 0;
w.Top =0;
w.Width = 1920;
w.Height = 1079;
}
The parameter w will be the MainWindow. When I execute that take a look how the window get's resized:
I placed the older image next to it so that you guys can compare it. Why are the dimensions not the same? I belive that the Window.Width and Window.Height properties do not work correctly. or what am I doing wrong?
Upvotes: 2
Views: 1498
Reputation: 30097
If you want to cover your main monitor then
Width = SystemParameters.PrimaryScreenWidth, Height = SystemParameters.PrimaryScreenHeight
if you want to cover both monitors
Width = SystemParameters.VirtualScreenWidth, Height = SystemParameters.VirtualScreenHeight
Upvotes: 4
Reputation: 1542
try out this
Width = SystemParameters.PrimaryScreenWidth, Height = SystemParameters.PrimaryScreenHeight,
Upvotes: 1