concept ColumnSpan in category silverlight

appears as: ColumnSp, The ColumnSp
Silverlight 4 in Action: Silverlight 4, MVVM, and WCF RIA Services

This is an excerpt from Manning's book Silverlight 4 in Action: Silverlight 4, MVVM, and WCF RIA Services.

Occasionally, you run into situations where you need to allow content to span multiple cells. You saw this in section 7.3.1, where we had a heading that demanded this functionality. As you saw then—to accomplish this, you need to use the ColumnSpan attached property.

The ColumnSpan attached property empowers you to spread content across several cells horizontally. By default, this integer value is set to 1, meaning that the content can occupy a single column. If this value is larger than the number of columns available in the row, the content extends to the end of the row but not beyond it. In addition to the ability to span horizontally, you can span vertically with RowSpan, which works just like ColumnSpan:

<TextBox Grid.Row="1" Grid.RowSpan="3"
Grid.Column="1" Grid.ColumnSpan="2" />

The ColumnSpan and RowSpan properties are easy to add to any piece of content in a Grid. Occasionally, though, allowing content to span multiple cells isn’t desirable, but you may need more space for content. Let’s look at the Grid’s sizing options.

Listing 7.6 shows a basic input form that uses a Grid to arrange its content. This content is arranged using a number of the Grid’s attached properties. The first attached property is ColumnSpan. This property gives you the ability to span an element across multiple cells. We’ll discuss this feature in greater detail in a moment. But first, we’ll cover the Grid.Row and Grid.Column attached properties. These properties are used more often and enable you to position content within a Grid.