Prev | Current Page 239 | Next

Matthew MacDonald

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

Finally, the text box needs to use automatic sizing mode, so it stretches to fit the entire
column.
Here??™s the markup you need to define the first row in the grid:
...

Height="Auto" VerticalAlignment="Center">

...

You can repeat this markup to add all your rows by simply incrementing the value of the
Grid.Row attribute.
One fact that??™s not immediately obvious is how flexible this window is because of the use
of the Grid control. None of the individual elements??”the labels, text boxes, and buttons??”
have hard-coded positions or sizes. As a result, you can quickly make changes to the entire
grid simply by tweaking the ColumnDefinition elements. Furthermore, if you add a row that
has longer label text (necessitating a wider first column), the entire grid is adjusted to be consistent,
including the rows that you??™ve already added. And if you want to add elements in
between the rows??”such as separator lines to divide different sections of the window??”you
can keep the same columns but use the ColumnSpan property to stretch a single element over
a larger area.


Pages:
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251