给窗体鼠标按下事件绑定处理方法
this.MouseDown += MainWindow_MouseDown;
在鼠标按下事件处理方法中实现拖拽和放大缩小
private void MainWindow_MouseDown(object sender, MouseButtonEventArgs e)
{
// 按下拖动
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
}
// 双击放大
if (e.ClickCount == 2 && e.ChangedButton == MouseButton.Left)
{
this.WindowState = this.WindowState == WindowState.Maximized ?
WindowState.Normal : WindowState.Maximized;
}
}