This is different than layout containers
such as the WrapPanel and StackPanel that create implicit rows or columns as they lay out their children.
If you want to create a grid that has more than one row and one column, you must define your rows and
columns explicitly using RowDefinition and ColumnDefinition objects.
Figure 4-12 shows how this simple grid appears at two different sizes. Notice that the
ShowGridLines property is set to True so that you can see the separation between each
column and row.
Figure 4-12. A simple grid
CHAPTER 4 n LAYOUT 95
As you would expect, the Grid honors the basic set of layout properties listed in Table 4-3.
That means you can add margins around the content in a cell, you can change the sizing
mode so an element doesn??™t grow to fill the entire cell, and you can align an item along one of
the edges of a cell. If you force an element to have a size that??™s larger than the cell can accommodate,
part of the content will be chopped off.
USING THE GRID IN VISUAL STUDIO
When you use a Grid on the Visual Studio design surface, you??™ll find that it works a bit differently than other
layout containers. As you drag an element into a Grid, Visual Studio allows you to place it in a precise position.
Visual Studio works this magic by setting the Margin property of your element.
Pages:
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224