Lifetime Events
All elements raise events when they are first created and when they are released. You can use
these events to initialize a window. Table 6-3 lists these events, which are defined in the
FrameworkElement class.
CHAPTER 6 n DEPENDENCY PROPERTIES AND ROUTED EVENTS 166
Table 6-3. Lifetime Events for All Elements
Name Description
Initialized Occurs after the element is instantiated and its properties have been
set according to the XAML markup. At this point, the element is
initialized, but other parts of the window may not be. Also, styles and
data binding haven??™t been applied yet. At this point, the IsInitialized
property is True. Initialized is an ordinary .NET event??”not a routed
event.
Loaded Occurs after the entire window has been initialized and styles and data
binding have been applied. This is the last stop before the element is
rendered. At this point, the IsLoaded property is True.
Unloaded Occurs when the element has been released, either because the containing
window has been closed or the specific element has been
removed from the window.
To understand how the Initialized and Loaded events relate, it helps to consider the rendering
process. The FrameworkElement implements the ISupportInitialize interface, which
provides two methods for controlling the initialization process.
Pages:
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331