------- <a href="http://www.itheima.com" target="blank">Windows Phone 7手機開發</a>、<a href="http://www.itheima.com" target="blank">.Net培訓</a>、期待與您交流! -------
1、導包:using System.Runtime.InteropServices;
2、將以下代碼放入類中:
[DllImport("user32.dll")]
public static extern bool ReleaseCapture();
[DllImport("user32.dll")]
public static extern bool SendMessage(IntPtrhwnd,int wMsg,intwParam,int lParam);
public const intWM_SYSCOMMAND = 0x0112;
public const int SC_MOVE =0xF010;
public const int HTCAPTION =0x0002;
3、設置窗體鼠標按下事件,在事件方法中黏貼如下代碼:
ReleaseCapture();
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MOVE + HTCAPTION, 0);