Prev | Current Page 253 | Next

Matthew MacDonald

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


Consider the example shown in Figure 5-2, which includes a simple image button that
places an Image element inside the Button control. This approach is less than ideal, because
bitmaps are not resolution independent. On a high-dpi display, the bitmap may appear blurry
because WPF must add more pixels by interpolation to make sure the image stays the correct
size. More sophisticated WPF interfaces avoid bitmaps and use a combination of vector
shapes to create custom-drawn buttons and other graphical frills (as you??™ll see in Chapter 13).
This approach integrates nicely with the content control model. Because the Button class
is a content control, you aren??™t limited to filling it with a fixed bitmap??”instead, you can
include other content. For example, you can use the classes in the System.Windows.Shapes
namespace to draw a vector image inside a button. Here??™s an example that creates a button
with two diamond shapes (as shown in Figure 5-4):

CHAPTER 5 n CONTENT 124
Figure 5-4. A button with shape content
Clearly, in this case the nested content model is simpler than adding extra properties to
the Button class to support the different types of content.


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