Prev | Current Page 199 | Next

Matthew MacDonald

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

However, it??™s rarely a good idea to take this step. Instead, use the maximum and
minimum size properties to lock your control into the right range, if necessary.
CHAPTER 4 n LAYOUT 86
nTip Think twice before setting an explicit size in WPF. In a well-designed layout, it shouldn??™t be necessary.
If you do add size information, you risk creating a more brittle layout that can??™t adapt to changes (such as
different languages and window sizes) and truncates your content.
For example, you might decide that the buttons in your StackPanel should stretch to fit
the StackPanel but be made no larger than 200 units wide and no smaller than 100 units wide.
(By default, buttons start with a minimum width of 75 units.) Here??™s the markup you need:







nTip At this point, you might be wondering if there??™s an easier way to set properties that are standardized
across several elements, such as the button margins in this example. The answer is styles??”a feature that
allows you to reuse property settings and even apply them automatically.


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