Reputation: 3604
I'm trying to override the onclose event on WPF, this is my code so far:
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
base.OnClosing(e);
e.Cancel = true;
//do my stuff before closing
}
It executes the code but the application never closes. Any ideas how to fix this?
Upvotes: 10
Views: 26629
Reputation: 34250
You are asking it not to close by setting e.Cancel = true
. Just don't do that.
Upvotes: 6
Reputation: 109027
The application never closes because you are setting e.Cancel
to true
.
Try
protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
{
//do my stuff before closing
base.OnClosing(e);
}
Upvotes: 19