title: WPF window covers taskbar
body: <p>I'm creating a custom WPF window with, WindowStyle=None, AllowsTransparency=True, and ResizeMode = CanMinimize.</p>
  
  <p>I have two events(That I created to understand events in WPF), PreviewMouseDoubleClick and PreviewMouseMove.</p>
  
  <p>Here's the XAML:</p>
  
  <pre><code>&lt;Style TargetType="{x:Type local:CustomWindow}"&gt;
      &lt;Setter Property="WindowStyle" Value="None"/&gt;
      &lt;Setter Property="AllowsTransparency" Value="True"/&gt;
      &lt;Setter Property="ResizeMode" Value="CanMinimize"/&gt;
      &lt;Setter Property="Template"&gt;
          &lt;Setter.Value&gt;
              &lt;ControlTemplate TargetType="{x:Type local:CustomWindow}"&gt;
                  &lt;Border BorderBrush="{TemplateBinding BorderBrush}" Background="{TemplateBinding Background}" BorderThickness="{TemplateBinding BorderThickness}"&gt;
                      &lt;Grid Background="{TemplateBinding GridBackground}"&gt;
                          &lt;ContentPresenter/&gt;
                      &lt;/Grid&gt;
                  &lt;/Border&gt;
              &lt;/ControlTemplate&gt;
          &lt;/Setter.Value&gt;
      &lt;/Setter&gt;
  &lt;/Style&gt;
  </code></pre>
  
  <p>Here's the Code Behind:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Threading.Tasks;
  using System.Windows;
  using System.Windows.Input;
  using System.Windows.Media;
  
  namespace CustomWindows
  {
      public class CustomWindow : Window
      {
          /* Dependency properties */
  
  
          public Brush GridBackground
          {
              get { return (Brush)GetValue(GridBackgroundProperty); }
              set { SetValue(GridBackgroundProperty, value); }
          }
  
          // Using a DependencyProperty as the backing store for GridBackground.  This enables animation, styling, binding, etc...
          public static readonly DependencyProperty GridBackgroundProperty =
              DependencyProperty.Register("GridBackground", typeof(Brush), typeof(Window), new PropertyMetadata(null));
  
  
  
  
          /* Constructors */
  
         static CustomWindow()
          {
              DefaultStyleKeyProperty.OverrideMetadata(typeof(CustomWindow), new FrameworkPropertyMetadata(typeof(CustomWindow)));
          }   
  
  
  
          /* overriders */
  
          public override void OnApplyTemplate()
          {
              PreviewMouseDoubleClick += (s, e) =&gt; 
              {
                  WindowState = (WindowState == WindowState.Maximized) ? WindowState.Normal : WindowState.Maximized;
              };
  
              PreviewMouseMove += (s, e) =&gt; 
              {
                  if(Mouse.LeftButton == MouseButtonState.Pressed)
                  {
                      DragMove();
                  }
              };
  
              base.OnApplyTemplate();
          }
      }
  }
  </code></pre>
  
  <p>On Dragging this window, it covers the taskbar. I am not sure as to why.
  Here's the link of the image that describes the behavior I'm talking about:
  <a href="http://imgur.com/ba3ADoL" rel="nofollow">http://imgur.com/ba3ADoL</a> <a href="http://imgur.com/ba3ADoL" rel="nofollow">Issue Description Image</a></p>
  
  <p>Also on restoring the window, if the mouse pointer is out of bounds of the window, the focus is still not given to Desktop. If the mouse is manually moved a bit later. Focus is given to Desktop. This behavior seems strange to me. Any help will be greatly appreciated.</p>
  
  <p>Thanks in Advance.</p>