开发者

How to override onclose event on WPF?

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 clos开发者_如何学Pythones. Any ideas how to fix this?


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);       
}


You are asking it not to close by setting e.Cancel = true. Just don't do that.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜