Cancelling Window close in WPF

Thursday, November 27, 2008 12:25

In this post we will avoid a window to be closed.

Forms in .NET 2.0 have the Closing event and this event has the e parameter of type ClosingEventArgs.

ClosingEventArgs has the Cancel property that if set to True will cancel the close procedure.

Visual Studio 2008 SP1 when used with a WPF project will generate an e parameter of type EventArgs. Just changing the type to ClosingEventArgs will do the job.

You can leave a response, or trackback from your own site.

Leave a Reply

Note: This post is over a year and a half old. You may want to check later in this blog to see if there is new information relevant to your comment.