Maximizing borderless window using SysParameter values

Earlier on, I had written a post on maximizing a borderless (WindowStyle=None) window but without covering the taskbar. This solution works well but was not that nice to look at implementation wise 🙂 ... However, theres a simplere solution to achieve the same. I get quite a few queries about the previous post, so I thought it would be a good idea to post this simple solution..


      Width="{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenWidthKey}}"

      Height="{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenHeightKey}}"



SystemParameters to the rescue... for the code behind version,

win.Height = SystemParameters.MaximizedPrimaryScreenHeight;

win.Width = SystemParameters.MaximizedPrimaryScreenWidth;

win.Top = 0;win.Left = 0;


Share this post


Comments (6)
  1. says:

    Presumably this only works if you maximize the window on the primary screen. Maximizing it on any other screen would have incorrect results.

  2. thats true… on multiple screens, the first solution is likely to work 🙂

  3. You’ve been kicked (a good thing) – Trackback from

  4. Felix says:

    This only works for the secondary screen when both screens have the same resolution! If the resolution is diffrent on secondary screen the window is sized be the width & height of the primery screen. I didnt found a solution to get the resolution (Width & Height)of the secondary screen.

  5. John says:

    In your original post, there was an issue where the window wouldn’t obey the minimum size when resizing.  It would cut off the right and bottom of the window.

    When I originally implemented a fix for this, it worked, but not for DPI settings larger than 96 (it would use the minTrackSize, but due to the difference in the way WPF and the MonitorInfo.ptMinTrackSize work, the minTrackSizewould not be accurate with larger DPI settings.

    To fix this,

    Add two private class variables:

    float desktopDpiX = 96f;

    float desktopDpiY = 96f;

    then, at the bottom of the SourceInitialized event, add:

    System.Drawing.Graphics desktop = System.Drawing.Graphics.FromHwnd(handle);

               desktopDpiX = desktop.DpiX;

               desktopDpiY = desktop.DpiY;

    finally, in the WmGetMinMaxInfo function, after:

    mmi.ptMaxSize.y = Math.Abs(rcWorkArea.bottom –;


    mmi.ptMinTrackSize.x = Convert.ToInt16(this.MinWidth * (desktopDpiX / 96));

                   mmi.ptMinTrackSize.y = Convert.ToInt16(this.MinHeight * (desktopDpiY / 96));

    This should fix the resizing issue and accurately adjust the minTrackSize based on the DPI settings.

    I hope this helps others with the same issue,

    John Rennemeyer


Comments are closed.

Skip to main content