Prev | Current Page 230 | Next

Matthew MacDonald

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

The Canvas is also the most lightweight of
the layout containers. That??™s because it doesn??™t include any complex layout logic to negotiate
the sizing preferences of its children. Instead, it simply lays them all out at the position they
specify, with the exact size they want.
To position an element on the Canvas, you set the attached Canvas.Left and Canvas.Top
properties. Canvas.Left sets the number of units between the left edge of your element and the
left edge of the Canvas. Canvas.Top sets the number of units between the top of your element
and the top of the Canvas. As always, these values are set in device-independent units, which
line up with ordinary pixels exactly when the system DPI is set to 96 dpi.
nNote Alternatively, you can use Canvas.Right instead of Canvas.Left to space an element from the right
edge of the Canvas, and Canvas.Bottom instead of Canvas.Top to space it from the bottom. You just can??™t
use both Canvas.Right and Canvas.Left at once, or both Canvas.Top and Canvas.Bottom.
Optionally, you can size your element explicitly using its Width and Height properties.
This is more common when using the Canvas than it is in other panels because the Canvas
has no layout logic of its own. (And often, you??™ll use the Canvas when you need precise control
over how a combination of elements is arranged.


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