Wiki Link: [discussion:914]
I just started 

Nov 10 2008 at 9:03 PM
I am a little surprised that there is no one in this discussion. Hopefully my question will be answered.

I just bought the book, and started on chapter 1. I also downloaded the Zip files with the vb equivalents of Petzold's book, thank you for the help.

1. Protected Overrides Sub OnSessionEnding(ByVal e As System.Windows.SessionEndingCancelEventArgs) never stops in the vb version of InheritTheApp.cs

I added a close windows intercept "Sub CloseWindow(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles win.Closing" which does intercept. Unfortunately the session ends anyway closing the window even though I canceled.
Any ideas?

2. If you use the normal Create WPF project, you must delete Application.xaml and Windows1.xaml or the code in Petzold will not work as provided. Furthermore, if you are using "STRICT" you need to fix the lack of a cast in MyWPFExtension from cType(Global.System.Windows.Application.Current,Application)
What is happening here?

Nov 12 2008 at 8:48 PM
I am probably just talking to myself, but I found that while Session ending does not work. The following work around does:
Public Sub WindowsClosing(ByVal sender As Object, ByVal e As System.ComponentModel.CancelEventArgs)
Dim x = CType(sender, Window)
If Me.Windows.Count = 1 Then
e.Cancel = MsgBox("Do you wish to close the last window and exit the program?", MsgBoxStyle.YesNo) = MsgBoxResult.No
End If
End Sub
It checks if this is the last window for the application. Since the application has Shutdownmode=OnLastWindowClose{0} this works by allowing the user to cancel the las windows closing.

Page view tracker