Prev | Current Page 269 | Next

Matthew MacDonald

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

This shape
is placed inside a Grid, and the Grid sizes itself just big enough to fit all the polygons inside.
If you enlarge the button, the shape doesn??™t change??”it??™s just centered inside the button (see
Figure 5-13). That??™s because the size of each polygon is set in absolute coordinates.
CHAPTER 5 n CONTENT 136
Figure 5-13. A resized graphical button
The scaling that the Viewbox does is similar to the scaling you see in WPF if you increase
the system DPI setting. It changes every onscreen element proportionately, including images,
text, lines and shapes, and the borders on common elements such as the button. If you revise
the button-with-a-shape example by wrapping the Grid in a Viewbox, you??™ll see the resizing
behavior that??™s shown in Figure 5-14:

Figure 5-14. A resized graphical button that uses a Viewbox
CHAPTER 5 n CONTENT 137
138 CHAPTER 5 n CONTENT
Even though the polygons in the Grid use hard-coded coordinates, the Viewbox is clever
enough to transform these coordinates. It decides how to transform them by comparing the
Grid??™s desired size??”the size it wants to make itself based on the shape content??”against the
available size.


Pages:
257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281