[英]How to move (Drag and Drop) wpf window when windows is maximized mode
How to move (Drag and Drop) wpf window when windows is maximized mode. 当窗口最大化模式时,如何移动(拖放)wpf窗口。 I am using below code but when window is maximized mode then its not working. 我使用下面的代码,但当窗口最大化模式,然后它不工作。
private void Window_MouseMove(object sender, MouseEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed)
{
this.DragMove();
}
}
How to fix this problem? 如何解决这个问题?
Use PreviewMouseLeftButtonDown Event, Change WindowState to Normal by code and after it apply DragMove Method. 使用PreviewMouseLeftButtonDown事件,通过代码将WindowState更改为Normal,然后应用DragMove方法。
private void Grid_PreviewMouseLeftButtonDown(object sender, MouseButtonEventArgs e)
{
if (WindowState == WindowState.Maximized)
{
WindowState = WindowState.Normal;
}
DragMove();
}
When subscribe to Mouse move evet you can change window enter code heresize and location. 订阅鼠标移动evet时,您可以更改窗口输入代码heresize和location。 For example 例如
`if (this.WindowState == WindowState.Maximized)
{
this.Width = this.ActualWidth;
this.Height = this.ActualHeight;
this.Left = 0;
this.Top = 0;
this.WindowStartupLocation = WindowStartupLocation.Manual;
this.WindowState = WindowState.Normal;
}`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.