Prev | Current Page 171 | Next

Matthew MacDonald

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

For this reason, the position of windows in the collection may change,
and you can??™t assume you??™ll find a specific window object at a specific position.
Interacting Between Windows
As you??™ve seen, the custom application class is a great place to put code that reacts to different
application events. There??™s one other purpose that an Application class can fill quite nicely:
storing references to important windows so one window can access another.
nTip This technique makes sense when you have a modeless window that lives for a long period of time
and might be accessed in several different classes (not just the class that created it). If you??™re simply showing
a modal dialog box as part of your application, this technique is overkill. In this situation, the window
won??™t exist for very long, and the code that creates the window is the only code that needs to access it.
(To brush up on the difference between modal windows, which interrupt application flow until they??™re closed,
and modeless windows, which don??™t, refer to Chapter 8.)
For example, imagine you want to keep track of all the document windows that your
application uses. To that end, you might create a dedicated collection in your custom application
class. Here??™s an example that uses a generic List collection to hold a group of custom
window objects.


Pages:
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183