WPF 实现自定义窗体时,窗体的拖拽和双击放大还原(最简版)
程序员文章站
2022-07-13 23:02:45
...
给窗体鼠标按下事件绑定处理方法
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;
}
}
Over
每次记录一小步...点点滴滴人生路...