开发者

Cancel Silverlight OOB Application Exit?

开发者 https://www.devze.com 2023-01-19 02:00 出处:网络
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 Applicati

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

0

精彩评论

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