O'Reilly logo

WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4 by Rod Stephens

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Appendix C. Layout Controls

This appendix summarizes controls that are designed to arrange and contain other controls. They help you position the controls that make up the user interface.

The following sections very briefly summarize these controls. They list the controls' most important properties and provide simple XAML examples. For more detail, see Chapter 6.

Many of the controls define attached properties for use by child controls to tell the layout control how to position the children. Tables in this appendix summarize the key attached properties.

Because these controls are designed to hold other controls, they make logical places to define styles. For example, to make all of the Labels inside a Grid use the same font styles, you can add an unnamed Label style to the Grid's Resources section.

Canvas

The Canvas is a very simple layout control that lets you arrange its contents by explicitly setting the distances between their edges and those of the Canvas. See Table C-1 for the key properties.

Table C.1. Key Properties of Canvas

Property

Purpose

Background

The color used to fill the control's interior

ClipToBounds

Determines whether the control clips its children to its boundaries.

A child control can use attached properties to tell the Canvas how to position the child. The key attached properties for Canvas are given in Table C-2.

Table C.2. Key Attached Properties of Canvas

Property

Purpose

Canvas.Bottom

Sets the distance between the child's bottom edge and the Canvas's bottom edge.

Canvas.Left ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required