日期:2014-05-17 浏览次数:21088 次
public partial class MainWindow { // 在类里增加下列定义 public const int WM_NCLBUTTONDOWN = 0xA1; public const int HT_CAPTION = 0x2; [DllImport("user32.dll")] public static extern int SendMessage(IntPtr hWnd, int msg, int wParam, int lParam); [DllImport("user32.dll")] public static extern bool ReleaseCapture(); public MainWindow() { InitializeComponent(); // 在Window的构造函数里增加下列语句: MouseLeftButtonDown += (o, args) => { var hwnd = new WindowInteropHelper(this).Handle; ReleaseCapture(); SendMessage(hwnd, WM_NCLBUTTONDOWN, HT_CAPTION, 0); }; } }
------解决方案--------------------
设置了WindowStyle = System.Windows.WindowStyle.None;吗?
private void Window_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { this.DragMove(); }
------解决方案--------------------
嗯嗯,第一种好
------解决方案--------------------
wpf拖放功能实现
http://www.cnblogs.com/loveis715/archive/2011/12/05/2277384.html