Prev | Current Page 421 | Next

Matthew MacDonald

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

That makes sure the dependency is well identified, and it adds another layer of indirection,
making it easier to accommodate changes to the window??™s interface.
nTip If the two windows have a complex interaction, are developed or deployed separately, or are likely to
change, you can consider going one step further and formalize their interaction by creating an interface with
the public methods and implementing that interface in your window class.
Figures 8-3 and 8-4 show two examples for implementing this pattern. Figure 8-3 shows
a window that triggers a second window to refresh its data in response to a button click. This
window does not directly attempt to modify the second window??™s user interface; instead, it
relies on a custom intermediate method called DoUpdate().
CHAPTER 8 n WINDOWS 226
Figure 8-3. A single window interaction
The second example, Figure 8-4, shows a case where more than one window needs to be
updated. In this case, the acting window relies on a higher-level application method, which
calls the required window update methods (perhaps by iterating through a collection of windows).
This approach is better because it works at a higher level. In the approach shown
Figure 8-3, the acting window doesn??™t need to know anything specific about the controls in
the receiving window.


Pages:
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433