Prev | Current Page 162 | Next

Matthew MacDonald

"Pro WPF with VB 2008: Windows Presentation Foundation with .NET 3.5"

You??™ll
learn more about how it works in Chapter 11.
CHAPTER 3 n THE APPLICATION 61
The second portion of the custom application class is stored in your project in a file like
Application.xaml.vb. It contains the event handling code you add. Initially, it??™s empty aside
from a comment:
Class Application
' Application-level events, such as Startup, Exit, and
' DispatcherUnhandledException can be handled in this file.
End Class
This file is merged with the automatically generated application code through the magic
of partial classes.
Application Shutdown
Ordinarily, the Application class keeps your application alive as long as at least one window is
still open. If this isn??™t the behavior you want, you can adjust the Application.ShutdownMode.
If you??™re instantiating your Application object by hand, you need to set the ShutdownMode
property before you call Run(). If you??™re using the Application.xaml file, you can simply set
the ShutdownMode property in the XAML markup.
You have three choices for the shutdown mode, as listed in Table 3-1.
Table 3-1.Values from the ShutdownMode Enumeration
Value Description
OnLastWindowClose This is the default behavior??”your application keeps running as long as
there is at least one window in existence. If you close the main window,
the Application.


Pages:
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174