Help - WPF Capture MainWindow Close Event

kimosavi

Active member
Joined
Apr 9, 2009
Messages
34
Location
Chicago, IL
Programming Experience
3-5
Hi,

I started a project using WPF Pages.

One Issue is that the Page Object does not have a Closed or Closing Event Handler. I search left and right and not even on the application.vb is there an event to stop and cancel the closing of the application.

I will like to Prompt the user BEFORE the application is closed and cancel the event in case the user clicked the close by mistake.

Has anyone achieved this in the past? I running out of Ideas/Options to do this.

Thanks!
 
Private Sub Window1_Closing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles Me.Closing
If Not MsgBox("do u want to close", MsgBoxStyle.YesNo) = MsgBoxResult.Yes Then
e.Cancel = True
End If
End Sub
 
Back
Top