请教WPF问题
最近在学WPF.有些不明白的地方,请教下....
之前写winfrom 想要无窗口的 panel自由移动,如下代码:
using System.Runtime.InteropServices; [DllImport("user32.dll")] public static extern bool SendMessage(IntPtr hwnd, int wMsg, int wParam, int lParam); private void panel2_MouseDown(object sender, MouseEventArgs e) { ReleaseCapture(); SendMessage(this.Handle, WM_SYSCOMMADN, SC_MOVE + HTCAPTION, 0); }//OK.没有问题,可以实现,但是到了WPF.就有点不相同了.//我在网上找到了一句代码.下面是WPF的代码 IntPtr hwnd = ((HwndSource)PresentationSource.FromVisual(canvas1)).Handle; SendMessage(hwnd, WM_SYSCOMMADN, SC_MOVE + HTCAPTION, 0);