Class ColumnDefinition

GoDiagram®
v10.0.10
by Northwoods Software®

The ColumnDefinition class describes constraints on a column in a Panel of type PanelLayoutTable. It also provides information about the actual layout after the Table Panel has been arranged.

Inheritance
ColumnDefinition
Namespace: Northwoods.Go
Assembly: Northwoods.GoDiagram.WinForms.dll
Syntax
public class ColumnDefinition

Constructors

ColumnDefinition()

You should not use this Constructor, because calls to GetColumnDefinition(int) will automatically create and remember a ColumnDefinition for you.

Declaration
public ColumnDefinition()

Properties

ActualWidth

Gets or sets the usable column width, after arrangement, in local coordinates, that elements in this column can be arranged within.

Declaration
public double ActualWidth { get; set; }
Property Value
Type Description
double
Remarks

This does not include SeparatorPadding or SeparatorStrokeWidth, as TotalWidth does.

The value is meaningless until after the Table Panel using this ColumnDefinition has been arranged.

It is very uncommon to set this property.

See Also

ActualX

Gets or sets the actual arranged column starting X position, after arrangement, in local coordinates.

Declaration
public double ActualX { get; set; }
Property Value
Type Description
double
Remarks

The value is meaningless until after the Table Panel using this ColumnDefinition has been arranged.

It is very uncommon to set this property.

See Also

Alignment

Gets or sets a default alignment for elements that are in this column.

Declaration
public Spot Alignment { get; set; }
Property Value
Type Description
Spot
Remarks

The value must be a Spot. The default value is Default, so that this ColumnDefinition does not supply any alignment information for the column.

When an element's Alignment property is Default, it gets the horizontal alignment from the element's column's Alignment and the vertical alignment from the element's row's Alignment. When that property is also Default, it takes the value from the table panel's DefaultAlignment property.

See Also

Background

Gets or sets the background color for a particular column, which fills the entire span of the column, including any SeparatorPadding.

Declaration
public Brush Background { get; set; }
Property Value
Type Description
Brush
Remarks

The default value is null, which means nothing is drawn in the background of the column.

See Also

Column

Gets or sets which column this ColumnDefinition describes in the Panel. The value is a zero-based integer.

Declaration
public int Column { get; init; }
Property Value
Type Description
int
Remarks

This property can only be set on init.

See Also

CoversSeparators

Gets or sets whether or not the Background, if there is one, is in front of or behind the separators.

Declaration
public bool CoversSeparators { get; set; }
Property Value
Type Description
bool
Remarks

The default value is false -- any background is drawn behind any separator lines.

MaxWidth

Gets or sets the maximum column width, in local coordinates.

Declaration
public double MaxWidth { get; set; }
Property Value
Type Description
double
Remarks

The value must be non-negative. The default value is Infinity. The arranged width of all elemnts in this column will be no greater than this value.

See Also

MinWidth

Gets or sets the minimum column width, in local coordinates.

Declaration
public double MinWidth { get; set; }
Property Value
Type Description
double
Remarks

The value must be non-negative and finite. The default value is zero. The arranged width of all elements in this column will be no less than this value.

See Also

Panel

This read-only property returns the Panel that this column definition is in.

Declaration
public Panel Panel { get; }
Property Value
Type Description
Panel

SeparatorDashArray

Gets or sets the dash array for dashing the separator line, provided this column has a nonzero SeparatorStrokeWidth and non-null SeparatorStroke.

Declaration
public float[] SeparatorDashArray { get; set; }
Property Value
Type Description
float[]
Remarks

Must be an array of positive numbers and zeroes, or else null to indicate a solid line.

For example, the array [5, 10] would create dashes of 5 pixels and spaces of 10 pixels.

Setting an array with all zeroes will set the value to null.

Default is null, so that this ColumnDefinition does not supply any stroke dash array information for what is drawn before the column. The separator line may still be drawn using dashes if DefaultColumnSeparatorDashArray is non-null.

See Also

SeparatorPadding

Gets or sets the additional padding for a particular column, in local coordinates.

Declaration
public Margin? SeparatorPadding { get; set; }
Property Value
Type Description
Margin?
Remarks

Padding is applied on two sides - before and after a column's contents. The SeparatorStrokeWidth comes before any padding Left.

The default value is null, so that this ColumnDefinition does not supply any padding information for the column. There may still be some padding between columns if DefaultSeparatorPadding is non-zero.

See Also

SeparatorStroke

Gets or sets the stroke (color) for the separator line that is drawn before a particular column, provided that column has a nonzero SeparatorStrokeWidth.

Declaration
public Brush SeparatorStroke { get; set; }
Property Value
Type Description
Brush
Remarks

The default value is null, so that this ColumnDefinition does not specify any brush for the separator line to draw before the column. The line may still be drawn if the value of DefaultColumnSeparatorStroke is non-null.

However, if no stroke color is specified, then no stroke width will be drawn, even if the SeparatorStrokeWidth value is non-zero.

See Also

SeparatorStrokeWidth

Gets or sets the stroke width for a particular column's separator line, in local coordinates.

Declaration
public double SeparatorStrokeWidth { get; set; }
Property Value
Type Description
double
Remarks

The default value is NaN, so that this ColumnDefinition does not supply any stroke width information for what is drawn before the column. The separator line may still be drawn if DefaultColumnSeparatorStroke is a real number (defaults to 1).

See Also

Sizing

Gets or sets how this column deals with a Table Panel's extra space.

Declaration
public Sizing Sizing { get; set; }
Property Value
Type Description
Sizing
Remarks

The default value is Default.

See Also

Stretch

Gets or sets the default stretch for elements that are in this column.

Declaration
public Stretch Stretch { get; set; }
Property Value
Type Description
Stretch
Remarks

The default value is Default, so that this ColumnDefinition does not supply any stretch information for the column.

When an element's Stretch property is Default, it gets the horizontal stretch from the element's column's Stretch and the vertical stretch from the element's row's Stretch. When that property is also Default, it takes the value from the table panel's DefaultStretch property.

See Also

TotalWidth

This read-only property returns the total arranged column width, after arrangement, in local coordinates.

Declaration
public double TotalWidth { get; }
Property Value
Type Description
double
Remarks

This value gives the ActualWidth size plus the SeparatorPadding and SeparatorStrokeWidth.

This value gives the horizontal space occupied by the column. The value is meaningless until after the Table Panel using this ColumnDefinition has been arranged.

See Also

Width

Gets or sets the column width, in local coordinates.

Declaration
public double Width { get; set; }
Property Value
Type Description
double
Remarks

The value must be non-negative and finite.

The default value is NaN, which means this Column will get a width that is just big enough to hold all of the elements in the column.

Setting this Value to a number will mean that all of the elements of this Panel in this Column will be allocated that amount of column width. Whether an element in the column is actually arranged to have that width depends on whether the Stretch stretches horizontally.

See Also

Methods

Apply(Action<ColumnDefinition>)

Applies the given function to this ColumnDefinition and returns it.

Declaration
public ColumnDefinition Apply(Action<ColumnDefinition> func)
Parameters
Type Name Description
Action<ColumnDefinition> func

the function to apply to the ColumnDefinition

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Remarks

This method is often used to apply some common styling to a number of templates.

// define some common property settings
void tableStyle(ColumnDefinition cd) {
  cd.Bind("SeparatorStroke", "Color");
}

var template1 =
  new Node("Table") { ... }
    .Add(
      new ColumnDefinition().Apply(tableStyle)
    );

var template2 =
  new Node("Table") { ... }
    .Add(
      new ColumnDefinition().Apply(tableStyle)
    );

Bind(params Binding[])

Add a number of data-bindings to this ColumnDefinition.

Declaration
public ColumnDefinition Bind(params Binding[] bindings)
Parameters
Type Name Description
Binding[] bindings

the Bindings

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Remarks

Do not add, modify, or remove object Bindings after this object has been copied.

Read more about Bindings at the Introduction page about Data Bindings.

Bind(IEnumerable<Binding>)

Add a number of data-bindings to this ColumnDefinition.

Declaration
public ColumnDefinition Bind(IEnumerable<Binding> bindings)
Parameters
Type Name Description
IEnumerable<Binding> bindings

a collection of Bindings

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Remarks

Do not add, modify, or remove object Bindings after this object has been copied.

Read more about Bindings at the Introduction page about Data Bindings.

Bind(string, SimpleConversion, BackConversion)

Add a data-binding to this ColumnDefinition for the given property name and optional conversion functions.

Declaration
public ColumnDefinition Bind(string prop, SimpleConversion conv, BackConversion backconv = null)
Parameters
Type Name Description
string prop

the source and target property name

SimpleConversion conv

an optional conversion function

BackConversion backconv

an optional back-conversion function

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Bind(string, SimpleConversion, SimpleConversion)

Add a data-binding to this ColumnDefinition for the given property name and optional conversion functions.

Declaration
public ColumnDefinition Bind(string prop, SimpleConversion conv, SimpleConversion backconv)
Parameters
Type Name Description
string prop

the source and target property name

SimpleConversion conv

an optional conversion function

SimpleConversion backconv

an optional back-conversion function

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Bind(string, TargetConversion, BackConversion)

Add a data-binding to this ColumnDefinition for the given property name and optional conversion functions.

Declaration
public ColumnDefinition Bind(string prop, TargetConversion conv = null, BackConversion backconv = null)
Parameters
Type Name Description
string prop

the source and target property name

TargetConversion conv

an optional conversion function

BackConversion backconv

an optional back-conversion function

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Bind(string, TargetConversion, SimpleConversion)

Add a data-binding to this ColumnDefinition for the given property name and optional conversion functions.

Declaration
public ColumnDefinition Bind(string prop, TargetConversion conv, SimpleConversion backconv)
Parameters
Type Name Description
string prop

the source and target property name

TargetConversion conv

an optional conversion function

SimpleConversion backconv

an optional back-conversion function

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Bind(string, string, SimpleConversion, BackConversion)

Add a data-binding to this ColumnDefinition for the given property names and conversion functions.

Declaration
public ColumnDefinition Bind(string targetprop, string sourceprop, SimpleConversion conv, BackConversion backconv = null)
Parameters
Type Name Description
string targetprop

the target property on the ColumnDefinition

string sourceprop

the source property on the data object

SimpleConversion conv

an optional conversion function

BackConversion backconv

an optional back-conversion function

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Bind(string, string, SimpleConversion, SimpleConversion)

Add a data-binding to this ColumnDefinition for the given property names and conversion functions.

Declaration
public ColumnDefinition Bind(string targetprop, string sourceprop, SimpleConversion conv, SimpleConversion backconv)
Parameters
Type Name Description
string targetprop

the target property on the ColumnDefinition

string sourceprop

the source property on the data object

SimpleConversion conv

an optional conversion function

SimpleConversion backconv

an optional back-conversion function

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Bind(string, string, TargetConversion, BackConversion)

Add a data-binding to this ColumnDefinition for the given property names and conversion functions.

Declaration
public ColumnDefinition Bind(string targetprop, string sourceprop, TargetConversion conv = null, BackConversion backconv = null)
Parameters
Type Name Description
string targetprop

the target property on the ColumnDefinition

string sourceprop

the source property on the data object

TargetConversion conv

an optional conversion function

BackConversion backconv

an optional back-conversion function

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Bind(string, string, TargetConversion, SimpleConversion)

Add a data-binding to this ColumnDefinition for the given property names and conversion functions.

Declaration
public ColumnDefinition Bind(string targetprop, string sourceprop, TargetConversion conv, SimpleConversion backconv)
Parameters
Type Name Description
string targetprop

the target property on the ColumnDefinition

string sourceprop

the source property on the data object

TargetConversion conv

an optional conversion function

SimpleConversion backconv

an optional back-conversion function

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Set(ColumnDefinition)

Set properties of this ColumnDefinition to the values of a "partial" ColumnDefinition.

Declaration
public ColumnDefinition Set(ColumnDefinition obj)
Parameters
Type Name Description
ColumnDefinition obj

the partial ColumnDefinition to use for setting properties

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Remarks

Only properties that are different from the default for the ColumnDefinition will be set in this manner.

For example, the following will only set the Alignment and Stretch properties:

myColDef.Set(new ColumnDefinition {
  Alignment = Spot.Left,
  Stretch = Stretch.Horizontal,
  MinWidth = 0  // won't be set, even if this ColumnDefinition's MinWidth isn't 0
})

Calling this method is much less efficient than setting properties directly. It's acceptable to call when constructing templates, as that will only happen once.

Set(object)

Set properties of this ColumnDefinition to the values of a given anonymous object.

Declaration
public ColumnDefinition Set(object props)
Parameters
Type Name Description
object props

the dynamic object of properties

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Remarks

Calling this method is much less efficient than setting properties directly. It's acceptable to call when constructing templates, as that will only happen once.

Set(string, object)

Set a property of this ColumnDefinition to a value.

Declaration
public ColumnDefinition Set(string propertyname, object value)
Parameters
Type Name Description
string propertyname

the name of the property to set

object value

the value to set the property to

Returns
Type Description
ColumnDefinition

this ColumnDefinition

Remarks

Calling this method is much less efficient than setting properties directly. It's acceptable to call when constructing templates, as that will only happen once.