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..

 <Window

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

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

      WindowStartupLocation="CenterScreen"

      WindowStyle="None"/>

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