title: How to remove border from a maximized WPF window?
body: <p>I want to run WPF application in fullscreen mode. For that I used the following code from <a href="http://www.codeproject.com/Articles/16618/How-To-Make-a-Windows-Form-App-Truly-Full-Screen-a" rel="nofollow noreferrer">this project</a>:</p>
  
  <pre><code>class WinApi
  {
      [DllImport("user32.dll", EntryPoint = "GetSystemMetrics")]
      public static extern int GetSystemMetrics(int which);
  
      [DllImport("user32.dll")]
      public static extern void
          SetWindowPos(IntPtr hwnd, IntPtr hwndInsertAfter,
                       int X, int Y, int width, int height, uint flags);        
  
      private const int SM_CXSCREEN = 0;
      private const int SM_CYSCREEN = 1;
      private static IntPtr HWND_TOP = IntPtr.Zero;
      private const int SWP_SHOWWINDOW = 64; // 0×0040
  
      public static int ScreenX
      {
          get { return GetSystemMetrics(SM_CXSCREEN);}
      }
  
      public static int ScreenY
      {
          get { return GetSystemMetrics(SM_CYSCREEN);}
      }
  
      public static void SetWinFullScreen(IntPtr hwnd)
      {
          SetWindowPos(hwnd, HWND_TOP, 0, 0, ScreenX, ScreenY, SWP_SHOWWINDOW);
      }
  }
  </code></pre>
  
  <p>In main .cs file I wrote the following code:</p>
  
  <pre><code>private void window1_KeyUp(object sender, KeyEventArgs e)
      {
  
          if(e.Key == Key.F)
          {
              if(!isFullScreen)
              {
                  height = mePlayer.Height;
                  width = mePlayer.Width;
                  this.BorderThickness = new Thickness(0.0);
                  this.Background = new SolidColorBrush(Colors.Black);
                  this.WindowStyle = WindowStyle.None;
                  this.WindowState = WindowState.Maximized;
                  this.Topmost = true;
                  WinApi.SetWinFullScreen(new WindowInteropHelper(this).Handle);
                  isFullScreen = !isFullScreen;
              }
              else
              {
                  this.Topmost = false;
                  this.Background = new SolidColorBrush(Colors.White);
                  this.WindowStyle = WindowStyle.SingleBorderWindow;
                  isFullScreen = !isFullScreen;
              }
          }
      }
  </code></pre>
  
  <p>The problem is that when I switch to fullscreen, I get this border around the window as shown in the screenshot below:</p>
  
  <p><img src="https://i.stack.imgur.com/sB5zF.jpg" alt="enter image description here"></p>
  
  <p>How to remove that border? Another issue is a thin dotted border around the window after restore to its original state. How to remove that also?</p>