Over Here…No, Wait, I Meant Over There!
One of the major tasks involved in software user experience design is determining what goes where, and why. Once you know what you want to show to a user and why you want to show it, you need a mechanism to address screen size and resolution. Fortunately, XAML (as part of WPF) addresses both these issues automagically.
XAML is rich with options for grouping page resources conveniently and ensuring that layout elements are positioned in a manner to enhance user experience. In addition, XAML elements by default dynamically size to fit their environment. As you can see, with XAML you can easily accommodate the most demanding UI designer's requirements.
When laying out a simple application's user interface, it's convenient to call on two subclasses of Panel
to do your heavy lifting: DockPanel
and StackPanel
. For more complex applications, Grid
is likely a smarter choice. As you might have guessed from their names, the primary function of these controls is the positioning of elements. They have the added feature of automatically placing elements in the order of their declaration in the XAML.
Tip
Review: In our examples, DockPanel
is used to lay out elements left to right (although attributes can be used to dock the elements to any border—left, right, top or bottom), while StackPanel
is used to stack elements one on top of the other.
We're going to use a fictional employee directory to explore how these controls interoperate with other elements and how ...
Get Programming .NET 3.5 now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.