WPF简单实用方法(持续更新)
1:点击退出提示框
MessageBoxResult result = MessageBox.Show("你真的要退出吗?", "", MessageBoxButton.YesNo); if (result == MessageBoxResult.Yes) { this.Close(); }
2:移动窗体
private void Border_MouseDown(object sender, MouseButtonEventArgs e) { this.DragMove(); }
3.最小化/最大化
private void Min_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) { this.WindowState = WindowState.Minimized; //this.WindowState = WindowState.Maximized;//最大化 }
4.窗体最大宽度、最大高度/窗体最小宽度、最小高度
public Evaluation() { this.MaxWidth = 980; this.MaxHeight = 566; this.MinWidth = 980; this.MinHeight = 566; InitializeComponent(); }