Way to make a Windowless WPF window draggable without getting InvalidOperationException

后端 未结 4 1893
囚心锁ツ
囚心锁ツ 2020-12-30 10:39

I have a borderless WPF main window. I\'m trying to make it so that the end user can drag the window.

I\'ve added the following to the Window\'s constructor:

<
4条回答
  •  半阙折子戏
    2020-12-30 11:12

    you can override the original method:

     public new void DragMove()
         {
            if (this.WindowState == WindowState.Normal)
            {
                SendMessage(hs.Handle, WM_SYSCOMMAND, (IntPtr)0xf012, IntPtr.Zero);
                SendMessage(hs.Handle, WM_LBUTTONUP, IntPtr.Zero, IntPtr.Zero);
            }
        }
    

提交回复
热议问题