title: WPF Borderless Window issues: Aero Snap & Maximizing
body: <p>I've created a borderless WPF window by setting the following window properties in XAML:</p>
  
  <pre><code>... WindowStyle="None" AllowsTransparency="True" ...
  </code></pre>
  
  <p><strong>This causes a number of issues:</strong></p>
  
  <p><strong>1) Resolved:</strong> It no longer has any built-in resize functionality</p>
  
  <p><strong>2) Resolved:</strong> It no longer has any built-in drag functionality</p>
  
  <p><strong>3) Resolved:</strong> Without the top toolbar, it no longer has minimize/maximize/restore/close buttons</p>
  
  <p><strong>4) Resolved:</strong> Maximizing via aero snap or setting WindowState prevents it from unsnapping.</p>
  
  <p><strong>5)</strong> Maximizing via aero snap or setting WindowState will use the whole screen as the boundary, overlapping the windows toolbar.</p>
  
  <p><strong>6)</strong> Maximizing via aero snap or setting WindowState seems to include a -7 margin, giving the window 7 pixels on each side that are beyond the edges of the window.</p>
  
  <p>1-3 were solved by making a xaml window template. I used invisible rectangles as handle regions, and some code behind that was applied via overriding OnApplyTemplate() to attach functionality via user32.dll SendMessage(...) for resize/move/minimize/maximize/restore/close.</p>
  
  <p>I found the answer to # 4 <a href="https://stackoverflow.com/questions/11703833/dragmove-and-maximize">here</a></p>
  
  <p>I tried solving 5-6 by intercepting the maximize message via WndProc and setting the size/position manually, but this had the issue of overwriting the RestoreRegion to the maximized size/position, removing the ability to restore the window. </p>
  
  <p>What's really odd is that resizing the window from the top border to the top of the screen triggers the aero full height snap just fine, with no issues at all.</p>
  
  <p>So, I've come a long way, but 5-6 is still an issue... is there a way to manually specify the maximize region? Or, is there a way to set the window size without affecting the restoreregion property? </p>