Prev | Current Page 211 | Next

Matthew MacDonald

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

In this example, each cell will be exactly the same
size, depending on the size of the containing window.
CHAPTER 4 n LAYOUT 94
To place individual elements into a cell, you use the attached Row and Column properties.
Both these properties take 0-based index numbers. For example, here??™s how you could
create a partially filled grid of buttons:

...





Each element must be placed into its cell explicitly. This allows you to place more than
one element into a cell (which rarely makes sense) or leave certain cells blank (which is often
useful). It also means you can declare your elements out of order, as with the final two buttons
in this example. However, it makes for clearer markup if you define your controls row by row,
and from right to left in each row.
There is one exception. If you don??™t specify the Grid.Row property, the Grid assumes that
it??™s 0. The same behavior applies to the Grid.Column property. Thus, you leave both attributes
off of an element to place it in the first cell of the Grid.
nNote The Grid fits elements into predefined rows and columns.


Pages:
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223