首先 WPF 如何实现无边框窗口
<Window ..... WindowStyle = "None"> ... </Window>
而当窗口实现无边框时,同时也无法实现鼠标移动窗体了。那么如何解决这一问题呢,如下列代码所示:
前台代码:
<Window ..... WindowStyle = "None" MouseLeftButtonDown="Window_MouseLeftButtonDown"> .... </Window>
后台代码:
1 private void Window_MouseLeftButtonDown(object sender, System.Windows.Input.MouseButtonEventArgs e) 2 { 3 if (e.LeftButton == System.Windows.Input.MouseButtonState.Pressed) 4 { 5 this.DragMove(); 6 } 7 }