Prev | Current Page 252 | Next

Matthew MacDonald

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

Content controls use a complementary property named
Padding, which inserts space between the edges of the control and the edges of the content.
To see the difference compare the following two buttons:


The button that has no padding (the default) has its text crowded up against the button
edge. The button that has a padding of 3 units on each side gets a more respectable amount
of breathing space. Figure 5-3 highlights the difference.
CHAPTER 5 n CONTENT 123
Figure 5-3. Padding the content of the button
nNote The HorizontalContentAlignment, VerticalContentAlignment, and Padding properties are all defined
as part of the Control class, not the more specific ContentControl class. That??™s because there may be controls
that aren??™t content controls but still have some sort of content. One example is the TextBox??”its contained
text (stored in the Text property) is adjusted using the alignment and padding settings you??™ve applied.
The WPF Content Philosophy
At this point, you might be wondering if the WPF content model is really worth all the trouble.
After all, you might choose to place an image inside a button but you??™re unlikely to embed
other controls and entire layout panels. However, there are a few important reasons driving
the shift in perspective.


Pages:
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264