"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.