WPF动作退出

时间:2017-09-13 20:52:45

标签: c# wpf exit

在wpf上我想知道用户何时按X退出。

然后我想做一些功能。

我怎样才能在wpf c#上做到?

1 个答案:

答案 0 :(得分:1)

public partial class MainWindow
{
    public MainWindow()
    {
        InitializeComponent();
        this.Closing += (sender, args) => ...; // Occurs after X is pressed. You can cancel closure here.
        this.Closed += (sender, args) => ...; // Occurs when the window is already closed.
    }
}