title: In WPF, when drag the customized titlebar in the no-border window, the window will be restored, how to implement it?
body: <p>I have customized a no-border window which is <code>no style</code> and <code>no border</code> and <code>AllowsTransparency="True"</code>, and in the top of this window there're a rectangle functionally instead of the build-in title bar. </p>
  
  <p>Generally, drag the title bar of the maximized window then the window will be restored, but in my customized no-border window, I no idea to implement it. Who can help me?</p>
  
  <p>This is simple code:</p>
  
  <pre><code>&lt;Window x:Class="WpfApplication24.MainWindow"
          xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
          xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
          Title="MainWindow" Height="350" Width="525"
          WindowStyle="None"
          AllowsTransparency="True"&gt;
      &lt;DockPanel LastChildFill="False"&gt;
          &lt;Rectangle DockPanel.Dock="Top" x:Name="DragRectangle" Height="30" Fill="#FF123456" MouseLeftButtonDown="DragRectangle_MouseLeftButtonDown"/&gt;
          &lt;Button x:Name="ToMaxButton" Content="ToMaxButton" Click="ToMaxButton_Click" Height="30" Margin="5"/&gt;
          &lt;Button x:Name="ToNormalButton" Content="ToNormalButton" Click="ToNormalButton_Click" Height="30" Margin="5"/&gt;
          &lt;Button x:Name="CloseButton" Content="CloseButton" Click="CloseButton_Click" Height="30" Margin="5"/&gt;
      &lt;/DockPanel&gt;
  &lt;/Window&gt;
  </code></pre>
  
  <p>and</p>
  
  <pre><code>namespace WpfApplication24
  {
      /// &lt;summary&gt;
      /// Interaction logic for MainWindow.xaml
      /// &lt;/summary&gt;
      public partial class MainWindow : Window
      {
          public MainWindow()
          {
              InitializeComponent();
          }
  
          private void DragRectangle_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
          {
              this.DragMove();
          }
  
          private void ToMaxButton_Click(object sender, RoutedEventArgs e)
          {
              this.WindowState = System.Windows.WindowState.Maximized;
          }
  
          private void CloseButton_Click(object sender, RoutedEventArgs e)
          {
              this.Close();
          }
  
          private void ToNormalButton_Click(object sender, RoutedEventArgs e)
          {
              this.WindowState = System.Windows.WindowState.Normal;
          }
      }
  }
  </code></pre>
  
  <p><strong>Edited:</strong></p>
  
  <p>Through by draging the original Window, we will find that we need drag a little distance then changed the window.state, then the position of the window will be that the coordinate of the cursor is nearly same.</p>