Prev | Current Page 200 | Next

Matthew MacDonald

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

You??™ll learn about styles in Chapter 12.
When the StackPanel sizes a button, it considers several pieces of information:
??? The minimum size. Each button will always be at least as large as the minimum size.
??? The maximum size. Each button will always be smaller than the maximum size (unless
you??™ve incorrectly set the maximum size to be smaller than the minimum size).
??? The content. If the content inside the button requires a greater width, the StackPanel
will attempt to enlarge the button. (You can find out the size that the button wants by
examining the DesiredSize property, which returns the minimum width or the content
width, whichever is greater.)
??? The size of the container. If the minimum width is larger than the width of the Stack-
Panel, a portion of the button will be cut off. Otherwise, the button will not be allowed
to grow wider than the StackPanel, even if it can??™t fit all its text on the button surface.
??? The horizontal alignment. Because the button uses a HorizontalAlignment of Stretch
(the default), the StackPanel will attempt to enlarge the button to fill the full width of
the StackPanel.
The trick to understanding this process is to realize that the minimum and maximum size
set the absolute bounds. Within those bounds, the StackPanel tries to respect the button??™s
desired size (to fit its content) and its alignment settings.


Pages:
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212