I have a windowless wpf application, whenever I set the window state as maximized it maximizes it on the primary display.
What I would like to do is have it maximize on
I had my application getting maximized in the secondary screen by doing this
Add this at the top of the main window :
using Screen = System.Windows.Forms.Screen;
Add this in the maximize handler :
private void AdjustWindowSize()
{
if (this.WindowState == WindowState.Maximized)
{
this.WindowState = WindowState.Normal;
}
else
{
System.Drawing.Rectangle r = Screen.GetWorkingArea(new System.Drawing.Point((int)this.Left, (int)this.Top));
this.MaxWidth = r.Width;
this.MaxHeight = r.Height;
this.WindowState = WindowState.Maximized;
}
}
Here we go !