Prev | Current Page 249 | Next

Matthew MacDonald

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

So far, the examples that
you??™ve seen that include buttons have simply supplied a string:

This string is set as the button content and displayed on the button surface. However, you
can get more ambitious by placing other elements inside the button. For example, you can
place an image inside using the Image class:

CHAPTER 5 n CONTENT 121
Or you could combine text and images by wrapping them all in a layout container like the
StackPanel:

You??™ll notice that this example uses the TextBlock instead of a Label control (although
either one would work). The TextBlock is a lightweight text element that supports wrapping
but doesn??™t support shortcut keys. Unlike the Label, the TextBlock is not a content control.
Chapter 7 describes both the TextBlock and Label in more detail.
nNote It??™s acceptable to place text content inside a content control because the XAML parser converts that
to a string object and uses that to set the Content property. However, you can??™t place string content directly
in a layout container.


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