Prev | Current Page 229 | Next

Matthew MacDonald

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


The UniformGrid
There is a grid that breaks all the rules you??™ve learned about so far: the UniformGrid. Unlike
the Grid, the UniformGrid doesn??™t require (or even support) predefined columns and rows.
Instead, you simply set the Rows and Columns properties to set its size. Each cell is always the
same size because the available space is divided equally. Finally, elements are placed into the
appropriate cell based on the order in which you define them. There are no attached Row and
Column properties, and no blank cells.
Here??™s an example that fills a UniformGrid with four buttons:






CHAPTER 4 n LAYOUT 106
The UniformGrid is used far less frequently than the Grid. The Grid is an all-purpose tool
for creating window layouts from the simple to the complex. The UniformGrid is a much more
specialized layout container that??™s primarily useful when quickly laying out elements in a rigid
grid (for example, when building a playing board for certain games). Many WPF programmers
will never use the UniformGrid.
Coordinate-Based Layout with the Canvas
The only layout container you haven??™t considered yet is the Canvas. It allows you to place elements
using exact coordinates, which is a poor choice for designing rich data-driven forms
and standard dialog boxes, but a valuable tool if you need to build something a little different
(such as a drawing surface for a diagramming tool).


Pages:
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241