Cancel Silverlight OOB Application Exit?
When the user closes my application I'd like to be able to prompt them with a confirmation if they have unsaved changes, and cancel the application's closing if they indicate to do so. The Application's Ex开发者_如何学JAVAit event does not allow cancellation. Is there any way to do this?
Catch the Closing event of the MainWindow instead:
App.Current.MainWindow.Closing += MainWindow_Closing;
Then you can set the Cancel property to true in the event handler if necessary:
private void MainWindow_Closing(object sender, System.ComponentModel.ClosingEventArgs e)
{
e.Cancel = true;
}
Hope this helps...
Chris
精彩评论