It also occurs the first time you show
a window.
Deactivated Occurs when a window in the application gets deactivated. This
occurs when you switch to another Windows program.
DispatcherUnhandledException Occurs when an unhandled exception occurs anywhere in your
application (on the main application thread). (The application
dispatcher catches these exceptions.) By responding to this
event, you can log critical errors, and you can even choose to
neutralize the exception and continue running your application
by setting the DispatcherUnhandledExceptionEventArgs.
Handled property to True. You should take this step only if you
can be guaranteed that the application is still in a valid state and
can continue.
WPF gives you several equivalent options for handling application events:
??? You can use the AddHandler statement in your code.
??? You can add the Handles clause to a method definition.
??? You can set the corresponding event attribute in the Application.xaml file.
All of these options are equivalent. Unlike the events that take place in a WPF window
(where the Handles clause sacrifices some capabilities), there??™s no difference when dealing
with application events.
For example, if you create this event handler to respond to unhandled exceptions:
Private Sub Application_DispatcherUnhandledException(ByVal sender As Object, _
ByVal e As DispatcherUnhandledExceptionEventArgs)
MessageBox.
Pages:
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178