20
Tôi biết rằng câu hỏi này rất giống với this one, nhưng tôi đã nghĩ rằng mã sau có thể đã hủy yêu cầu tắt máy, nhưng không? Bất cứ ai có thể giải thích lý do tại sao?Hủy đóng cửa sổ trong WPF
namespace WpfApplication1
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
this.Closing += new System.ComponentModel.CancelEventHandler(MainWindow_Closing);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
Application.Current.Shutdown();
}
void MainWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
e.Cancel = true;
}
}
}