Skip to end of metadata
Go to start of metadata

Remarks

Table is a Block element that supports grid-based presentation consisting of columns (represented by TableColumn elements) and rows (represented by TableRow elements). TableColumn elements do not host content; they simply define columns and characteristics of columns. TableRow elements must be hosted in a TableRowGroup element, which defines a grouping of rows for the table. TableCell elements, which contain the actual content to be presented by the table, must be hosted in a TableRow element. TableCell element may not directly host text content. It can only contains Block elements.

XAML

Working with Borders Property

In Table element, you can add two more border definition in Borders property. The fifth definition specifies inside horizontal border formatting, while the sixth definition specifies the inside vertical border formatting. For example: Borders="1,Single,#FF000000;1,Single,#FF000000;1,Single,#FF000000;1,Single,#FF000000;1,Single,#FF0000FF;1,Single,#FF0000FF;" will apply Blue color as the color of horizontal and vertical lines of all TableCell elements in the table. Note that this six border definition can only be applied to Table element.

XAML

Working with CellPadding Property and CellSpacing Property

You can specify cell spacing and cell padding in Table element using CellSpacing and CellPadding properties respectively. CellSpacing property determines the spacing between each cells, while CellPadding property determines default padding applied to each TableCell. Note that when CellSpacing is set to 0, the border definitions will automatically collapse to a single border definition. For further information about Table border definition, see Understanding Table Formatting.

XAML

Working with Columns Property

You can specify the width of each column in TableColumn element. Similar to Grid, you can input a double length value, or use Auto and Star (*) unit type as the value of the Width property. Note that the column width specified will not always be applied as the width of the cell. If CellSpacing and border formatting are specified in Table element, the width of the cell will be the result of the column width subtracted with these values.

XAML

In the above code, three TableColumn elements are specified in the Table. The width of the first, second, and third column is 100, Auto, and 2* respectively. Note that Auto is equal to one-star (*) value.

TableColumn is not inherited from TextElement, so you cannot specify common flow element formatting in this element.

Working with InsideHorizontalBorderBrush Property, InsideHorizontalBorderStyle Property, InsideHorizontalBorderThickness Property, InsideVerticalBorderBrush Property, InsideVerticalBorderStyle Property, InsideVerticalBorderThickness Property

Besides the left, top, right, and bottom individual border formatting, you can specify inside horizontal and inside vertical border formatting in Table level. When inside horizontal and inside vertical border formatting are specified, it will be used as the border format applied to the horizontal and vertical border of all TableCell elements in the Table. To specify these, simply set these additional border properties, InsideHorizontalBorderBrush, InsideHorizontalBorderStyle, InsideHorizontalBorderThickness, InsideVerticalBorderBrush, InsideVerticalBorderStyle, and InsideVerticalBorderThickness.

XAML

Working with RowGroups Property

TableRowGroup element provides a way to arbitrarily group rows within a table; every row in a table must belong to a row grouping. Rows within a row group often share a common intent, and may be styled as a group. A common use for row groupings is to separate special-purpose rows, such as a title, header, and footer rows, from the primary content contained by the table.

XAML

In the above code, the first TableRowGroup is styled as a group row, while the next one is styled as a common row. Note that the formatting styles are applied in TableRowGroup level.

You can specify Height, MinHeight, and MaxHeight in TableRowGroup and TableRow elements. When these properties are configured in TableRowGroup, it will be applied to all rows contained in the row group. When a specific height is specified in TableRow, the content will be clipped if it exceeds the specified height.

Working with Width Property

By default, Table element will use the width of the available document width. To specify a custom width value, you can either use Width property or specify a double length value as the width of each TableColumn definition. For example, if you have four columns and specify 100 as the width of each TableColumn , the width of Table element will be 400 pixel. On the other hand, you cannot specify the height of the Table element. Table element will consume the total height as the result of the flowing content in each cell. You can specify height definition in TableRow level. For further information about TableRow, see Understanding TableRow.

XAML

Note that, if you specify Auto or Star value as one of the TableColumn width, the Table element will use the available document width.

Definition

public class Table : Block

Summary

The following table summarizes the members exposed in this class.

Public Constructors

Table Constructor()Initializes a new instance of the Table class.

Public Properties

ApplyTableBorderToCell 
BordersGets or sets the comma and semicolon separated string as border value.
CellPaddingGets or sets the global padding that will be applied to all TableCell elements.
CellSpacingGets or sets the spacing between cells in table.
ColumnsGets or sets the column collection of the table.
InsideHorizontalBorderBrushGets or sets the Brush that will be applied to all horizontal border of cells.
InsideHorizontalBorderStyleGets or sets the border line style that will be applied to all horizontal border of cells.
InsideHorizontalBorderThicknessGets or sets the thickness that will be applied to all horizontal border of cells.
InsideVerticalBorderBrushGets or sets the Brush that will be applied to all vertical border of cells.
InsideVerticalBorderStyleGets or sets the border line style that will be applied to all vertical border of cells.
InsideVerticalBorderThicknessGets or sets the thickness that will be applied to all vertical border of cells.
RowGroupsGets or sets the TableRowGroup collections of the table.
WidthGets or sets the width of the table.

Fields

ApplyTableBorderToCellPropertyIdentifies the ApplyTableBorderToCell dependency property.
BordersPropertyIdentifies the Borders dependency property.
CellPaddingPropertyIdentifies the CellPadding dependency property.
CellSpacingPropertyIdentifies the CellSpacing dependency property.
ColumnsPropertyIdentifies the Columns dependency property.
InsideHorizontalBorderBrushPropertyIdentifies the InsideHorizontalBorderBrush dependency property.
InsideHorizontalBorderStylePropertyIdentifies the InsideHorizontalBorderStyle dependency property.
InsideHorizontalBorderThicknessPropertyIdentifies the InsideHorizontalBorderThickness dependency property.
InsideVerticalBorderBrushPropertyIdentifies the InsideVerticalBorderBrush dependency property.
InsideVerticalBorderStylePropertyIdentifies the InsideVerticalBorderStyle dependency property.
InsideVerticalBorderThicknessPropertyIdentifies the InsideVerticalBorderThickness dependency property.
RowGroupsPropertyIdentifies the RowGroups dependency property.
WidthPropertyIdentifies the Width dependency property.

Public Constructors

public Table()

Initializes a new instance of the Table class.

Public Properties

public bool ApplyTableBorderToCell { get; set; }

 

public TableBorderStyle Borders { get; set; }

Gets or sets the comma and semicolon separated string as border value.

public double CellPadding { get; set; }

Gets or sets the global padding that will be applied to all TableCell elements.

public double CellSpacing { get; set; }

Gets or sets the spacing between cells in table.

public TableColumnCollection Columns { get; set; }

Gets or sets the column collection of the table.

public Brush InsideHorizontalBorderBrush { get; set; }

Gets or sets the Brush that will be applied to all horizontal border of cells.

public BorderLineStyle InsideHorizontalBorderStyle { get; set; }

Gets or sets the border line style that will be applied to all horizontal border of cells.

public double InsideHorizontalBorderThickness { get; set; }

Gets or sets the thickness that will be applied to all horizontal border of cells.

public Brush InsideVerticalBorderBrush { get; set; }

Gets or sets the Brush that will be applied to all vertical border of cells.

public BorderLineStyle InsideVerticalBorderStyle { get; set; }

Gets or sets the border line style that will be applied to all vertical border of cells.

public double InsideVerticalBorderThickness { get; set; }

Gets or sets the thickness that will be applied to all vertical border of cells.

public TableRowGroupCollection RowGroups { get; set; }

Gets or sets the TableRowGroup collections of the table.

public double Width { get; set; }

Gets or sets the width of the table.

Fields

public static readonly DependencyProperty ApplyTableBorderToCellProperty

Identifies the ApplyTableBorderToCell dependency property.

public static readonly DependencyProperty BordersProperty

Identifies the Borders dependency property.

public static readonly DependencyProperty CellPaddingProperty

Identifies the CellPadding dependency property.

public static readonly DependencyProperty CellSpacingProperty

Identifies the CellSpacing dependency property.

public static readonly DependencyProperty ColumnsProperty

Identifies the Columns dependency property.

public static readonly DependencyProperty InsideHorizontalBorderBrushProperty

Identifies the InsideHorizontalBorderBrush dependency property.

public static readonly DependencyProperty InsideHorizontalBorderStyleProperty

Identifies the InsideHorizontalBorderStyle dependency property.

public static readonly DependencyProperty InsideHorizontalBorderThicknessProperty

Identifies the InsideHorizontalBorderThickness dependency property.

public static readonly DependencyProperty InsideVerticalBorderBrushProperty

Identifies the InsideVerticalBorderBrush dependency property.

public static readonly DependencyProperty InsideVerticalBorderStyleProperty

Identifies the InsideVerticalBorderStyle dependency property.

public static readonly DependencyProperty InsideVerticalBorderThicknessProperty

Identifies the InsideVerticalBorderThickness dependency property.

public static readonly DependencyProperty RowGroupsProperty

Identifies the RowGroups dependency property.

public static readonly DependencyProperty WidthProperty

Identifies the Width dependency property.

  • No labels