Class ColumnDefinition
- Namespace
- Northwoods.Go
- Assembly
- Northwoods.GoDiagram.WinForms.dll
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.
public class ColumnDefinition
- Inheritance
-
ColumnDefinition
- Inherited Members
Constructors
ColumnDefinition()
You should not use this Constructor, because calls to GetColumnDefinition(int) will automatically create and remember a ColumnDefinition for you.
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.
public double ActualWidth { get; set; }
Property Value
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.
public double ActualX { get; set; }
Property Value
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.
public Spot Alignment { get; set; }
Property Value
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.
public Brush Background { get; set; }
Property Value
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.
public int Column { get; init; }
Property Value
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.
public bool CoversSeparators { get; set; }
Property Value
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.
public double MaxWidth { get; set; }
Property Value
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.
public double MinWidth { get; set; }
Property Value
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.
public Panel Panel { get; }
Property Value
SeparatorDashArray
Gets or sets the dash array for dashing the separator line, provided this column has a nonzero SeparatorStrokeWidth and non-null SeparatorStroke.
public float[] SeparatorDashArray { get; set; }
Property Value
- 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.
public Margin? SeparatorPadding { get; set; }
Property Value
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.
public Brush SeparatorStroke { get; set; }
Property Value
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.
public double SeparatorStrokeWidth { get; set; }
Property Value
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.
public Sizing Sizing { get; set; }
Property Value
Remarks
The default value is Default.
- See Also
Stretch
Gets or sets the default stretch for elements that are in this column.
public Stretch Stretch { get; set; }
Property Value
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.
public double TotalWidth { get; }
Property Value
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.
public double Width { get; set; }
Property Value
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.
public ColumnDefinition Apply(Action<ColumnDefinition> func)
Parameters
func
Action<ColumnDefinition>the function to apply to the ColumnDefinition
Returns
- 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.
public ColumnDefinition Bind(params Binding[] bindings)
Parameters
bindings
Binding[]the Bindings
Returns
- 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.
public ColumnDefinition Bind(IEnumerable<Binding> bindings)
Parameters
bindings
IEnumerable<Binding>a collection of Bindings
Returns
- 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.
public ColumnDefinition Bind(string prop, SimpleConversion conv, BackConversion backconv = null)
Parameters
prop
stringthe source and target property name
conv
SimpleConversionan optional conversion function
backconv
BackConversionan optional back-conversion function
Returns
- ColumnDefinition
this ColumnDefinition
Bind(string, SimpleConversion, SimpleConversion)
Add a data-binding to this ColumnDefinition for the given property name and optional conversion functions.
public ColumnDefinition Bind(string prop, SimpleConversion conv, SimpleConversion backconv)
Parameters
prop
stringthe source and target property name
conv
SimpleConversionan optional conversion function
backconv
SimpleConversionan optional back-conversion function
Returns
- ColumnDefinition
this ColumnDefinition
Bind(string, TargetConversion, BackConversion)
Add a data-binding to this ColumnDefinition for the given property name and optional conversion functions.
public ColumnDefinition Bind(string prop, TargetConversion conv = null, BackConversion backconv = null)
Parameters
prop
stringthe source and target property name
conv
TargetConversionan optional conversion function
backconv
BackConversionan optional back-conversion function
Returns
- ColumnDefinition
this ColumnDefinition
Bind(string, TargetConversion, SimpleConversion)
Add a data-binding to this ColumnDefinition for the given property name and optional conversion functions.
public ColumnDefinition Bind(string prop, TargetConversion conv, SimpleConversion backconv)
Parameters
prop
stringthe source and target property name
conv
TargetConversionan optional conversion function
backconv
SimpleConversionan optional back-conversion function
Returns
- ColumnDefinition
this ColumnDefinition
Bind(string, string, SimpleConversion, BackConversion)
Add a data-binding to this ColumnDefinition for the given property names and conversion functions.
public ColumnDefinition Bind(string targetprop, string sourceprop, SimpleConversion conv, BackConversion backconv = null)
Parameters
targetprop
stringthe target property on the ColumnDefinition
sourceprop
stringthe source property on the data object
conv
SimpleConversionan optional conversion function
backconv
BackConversionan optional back-conversion function
Returns
- ColumnDefinition
this ColumnDefinition
Bind(string, string, SimpleConversion, SimpleConversion)
Add a data-binding to this ColumnDefinition for the given property names and conversion functions.
public ColumnDefinition Bind(string targetprop, string sourceprop, SimpleConversion conv, SimpleConversion backconv)
Parameters
targetprop
stringthe target property on the ColumnDefinition
sourceprop
stringthe source property on the data object
conv
SimpleConversionan optional conversion function
backconv
SimpleConversionan optional back-conversion function
Returns
- ColumnDefinition
this ColumnDefinition
Bind(string, string, TargetConversion, BackConversion)
Add a data-binding to this ColumnDefinition for the given property names and conversion functions.
public ColumnDefinition Bind(string targetprop, string sourceprop, TargetConversion conv = null, BackConversion backconv = null)
Parameters
targetprop
stringthe target property on the ColumnDefinition
sourceprop
stringthe source property on the data object
conv
TargetConversionan optional conversion function
backconv
BackConversionan optional back-conversion function
Returns
- ColumnDefinition
this ColumnDefinition
Bind(string, string, TargetConversion, SimpleConversion)
Add a data-binding to this ColumnDefinition for the given property names and conversion functions.
public ColumnDefinition Bind(string targetprop, string sourceprop, TargetConversion conv, SimpleConversion backconv)
Parameters
targetprop
stringthe target property on the ColumnDefinition
sourceprop
stringthe source property on the data object
conv
TargetConversionan optional conversion function
backconv
SimpleConversionan optional back-conversion function
Returns
- ColumnDefinition
this ColumnDefinition
BindTwoWay(string, SimpleConversion, BackConversion)
This convenience function works like Bind(string, TargetConversion, BackConversion), creating a Binding, then also calls MakeTwoWay(BackConversion) on it.
public ColumnDefinition BindTwoWay(string prop, SimpleConversion conv, BackConversion backconv = null)
Parameters
prop
stringA string naming the source and target property on the target object. This should not be the empty-string.
conv
SimpleConversionAn optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place.
backconv
BackConversionAn optional conversion function to convert property values back to data values. Specifying this modifies the binding to set its Mode to be TwoWay.
Returns
- ColumnDefinition
this ColumnDefinition
Remarks
Read more about Bindings at the Introduction page about Data Bindings.
BindTwoWay(string, SimpleConversion, SimpleConversion)
This convenience function works like Bind(string, TargetConversion, BackConversion), creating a Binding, then also calls MakeTwoWay(BackConversion) on it.
public ColumnDefinition BindTwoWay(string prop, SimpleConversion conv, SimpleConversion backconv)
Parameters
prop
stringA string naming the source and target property on the target object. This should not be the empty-string.
conv
SimpleConversionAn optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place.
backconv
SimpleConversionAn optional conversion function to convert property values back to data values. Specifying this modifies the binding to set its Mode to be TwoWay.
Returns
- ColumnDefinition
this ColumnDefinition
Remarks
Read more about Bindings at the Introduction page about Data Bindings.
BindTwoWay(string, TargetConversion, BackConversion)
This convenience function works like Bind(string, TargetConversion, BackConversion), creating a Binding, then also calls MakeTwoWay(BackConversion) on it.
public ColumnDefinition BindTwoWay(string prop, TargetConversion conv = null, BackConversion backconv = null)
Parameters
prop
stringA string naming the source and target property on the target object. This should not be the empty-string.
conv
TargetConversionAn optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place.
backconv
BackConversionAn optional conversion function to convert property values back to data values. Specifying this modifies the binding to set its Mode to be TwoWay.
Returns
- ColumnDefinition
this ColumnDefinition
Remarks
Read more about Bindings at the Introduction page about Data Bindings.
BindTwoWay(string, TargetConversion, SimpleConversion)
This convenience function works like Bind(string, TargetConversion, BackConversion), creating a Binding, then also calls MakeTwoWay(BackConversion) on it.
public ColumnDefinition BindTwoWay(string prop, TargetConversion conv, SimpleConversion backconv)
Parameters
prop
stringA string naming the source and target property on the target object. This should not be the empty-string.
conv
TargetConversionAn optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place.
backconv
SimpleConversionAn optional conversion function to convert property values back to data values. Specifying this modifies the binding to set its Mode to be TwoWay.
Returns
- ColumnDefinition
this ColumnDefinition
Remarks
Read more about Bindings at the Introduction page about Data Bindings.
BindTwoWay(string, string, SimpleConversion, BackConversion)
This convenience function works like Bind(string, string, TargetConversion, BackConversion), creating a Binding, then also calls MakeTwoWay(BackConversion) on it.
public ColumnDefinition BindTwoWay(string targetprop, string sourceprop, SimpleConversion conv, BackConversion backconv = null)
Parameters
targetprop
stringA string naming the target property on the target object. This should not be the empty-string.
sourceprop
stringA string name the source property on the bound data object If this is the empty string, the whole Data object is used.
conv
SimpleConversionAn optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place.
backconv
BackConversionAn optional conversion function to convert property values back to data values. Specifying this modifies the binding to set its Mode to be TwoWay.
Returns
- ColumnDefinition
this ColumnDefinition
Remarks
Read more about Bindings at the Introduction page about Data Bindings.
BindTwoWay(string, string, SimpleConversion, SimpleConversion)
This convenience function works like Bind(string, string, TargetConversion, BackConversion), creating a Binding, then also calls MakeTwoWay(BackConversion) on it.
public ColumnDefinition BindTwoWay(string targetprop, string sourceprop, SimpleConversion conv, SimpleConversion backconv)
Parameters
targetprop
stringA string naming the target property on the target object. This should not be the empty-string.
sourceprop
stringA string name the source property on the bound data object If this is the empty string, the whole Data object is used.
conv
SimpleConversionAn optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place.
backconv
SimpleConversionAn optional conversion function to convert property values back to data values. Specifying this modifies the binding to set its Mode to be TwoWay.
Returns
- ColumnDefinition
this ColumnDefinition
Remarks
Read more about Bindings at the Introduction page about Data Bindings.
BindTwoWay(string, string, TargetConversion, BackConversion)
This convenience function works like Bind(string, string, TargetConversion, BackConversion), creating a Binding, then also calls MakeTwoWay(BackConversion) on it.
public ColumnDefinition BindTwoWay(string targetprop, string sourceprop, TargetConversion conv = null, BackConversion backconv = null)
Parameters
targetprop
stringA string naming the target property on the target object. This should not be the empty-string.
sourceprop
stringA string name the source property on the bound data object If this is the empty string, the whole Data object is used.
conv
TargetConversionAn optional side-effect-free function converting the data property value to the value to set the target property. If the function is null or not supplied, no conversion takes place.
backconv
BackConversionAn optional conversion function to convert property values back to data values. Specifying this modifies the binding to set its Mode to be TwoWay.
Returns
- ColumnDefinition
this ColumnDefinition
Remarks
Read more about Bindings at the Introduction page about Data Bindings.
BindTwoWay(string, string, TargetConversion, SimpleConversion)
Add a data-binding to this ColumnDefinition for the given property names and conversion functions.
public ColumnDefinition BindTwoWay(string targetprop, string sourceprop, TargetConversion conv, SimpleConversion backconv)
Parameters
targetprop
stringthe target property on the ColumnDefinition
sourceprop
stringthe source property on the data object
conv
TargetConversionan optional conversion function
backconv
SimpleConversionan optional back-conversion function
Returns
- ColumnDefinition
this ColumnDefinition
Set(ColumnDefinition)
Set properties of this ColumnDefinition to the values of a "partial" ColumnDefinition.
public ColumnDefinition Set(ColumnDefinition obj)
Parameters
obj
ColumnDefinitionthe partial ColumnDefinition to use for setting properties
Returns
- 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.
public ColumnDefinition Set(object props)
Parameters
props
objectthe dynamic object of properties
Returns
- 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.
public ColumnDefinition Set(string propertyname, object value)
Parameters
Returns
- 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.