Prev | Current Page 208 | Next

Matthew MacDonald

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


CHAPTER 4 n LAYOUT 92
nNote In this example, the Padding adds some minimum space between the button border and the content
inside (the word ???OK??? or ???Cancel???). You??™ll learn more about Padding when you consider content controls
in Chapter 5.
Figure 4-11. A basic dialog box
At first glance, this seems like a fair bit more work than placing controls in precise positions
using coordinates in a traditional Windows Forms application. And in many cases, it is.
However, the longer setup time is compensated by the ease with which you can change the
user interface in the future. For example, if you decide you want the OK and Cancel buttons
to be centered at the bottom of the window, you simply need to change the alignment of the
StackPanel that contains them:

This design??”a simple window with centered buttons??”already demonstrates an end
result that wasn??™t possible with Windows Forms in .NET 1.x (at least not without writing code)
and required the specialized layout containers with Windows Forms in .NET 2.0. And if you??™ve
ever looked at the designer code generated by the Windows Forms serialization process, you??™ll
realize that the markup used here is cleaner, simpler, and more compact. If you add a dash of
styles to this window (Chapter 12), you can improve it even further and remove other extraneous
details (such as the margin settings) to create a truly adaptable user interface.


Pages:
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220