2017-09-13 7 views
-5

wpf에서 사용자가 X을 눌러 종료하는 것을 알고 싶습니다.WPF 동작 befor exit

그런 다음 몇 가지 기능을 수행하고 싶습니다.

wpf C#에서 어떻게 할 수 있습니까?

답변

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. 
    } 
}