Cancelling WPF Application.Shutdown
Posted
by MarkPearl
on Geeks with Blogs
See other posts from Geeks with Blogs
or by MarkPearl
Published on Thu, 06 Jan 2011 12:06:27 GMT
Indexed on
2011/01/06
12:54 UTC
Read the original article
Hit count: 178
Today I spent the better part of an hour trying to figure out what I had had done wrong. I had an application that when the user click’s “exit”, it should prompt if they want to save the last unsaved file, or cancel the exit. If the select cancel it should not exit the application. Everything seemed fine in my code, all I was doing was calling
Application.Current.Shutdown();
And then capturing the Closing event and setting cancel to true.. (see SO question here)
Long story short, If should not have been calling Application.Current.Shutdown() but rather Application.Current.MainWindow.Close().
grrrr… <I must read documentation properly>
© Geeks with Blogs or respective owner