BaseFieldDefinition
This is the base class for all field definition classes. These are responsible for creating the input controls and labels that appear on AutoFormPanel components.
Properties
public String PropertyName { get; set; } Holds the name of the property which the input control will be bound to.
public String Title { get; set; } Holds the text which will be displayed in the label associated with the input control. If this is blank or null, the value of
PropertyName will be converted to readable text using
Humanizer.
public bool EnabledPropertyName { get; set; } Optionally holds the name of a property to which the input controls
IsEnabled property will be bound. This lets you use a property of the model object to control whether input controls are enabled or not.
public bool InvertEnabledState { get; set; } If this Boolean property is true, the value of the property named in
EnabledPropertyName will be inverted when applied to the input controls
IsEnabled property. This is useful if you are using a property to control whether input controls are enabled - say one called
ApplicationIsBusy . Set
InvertEnabledState to
true for an
OK button and
false for a
Cancel button, and your buttons are enabled correctly depending on whether your application is busy or not.
public Control InputControl { get; protected set; } Sets or returns the input control associated with the property this field definition represents. If the control hasn't been built yet,
BuildInputControl() is called first.
public Control ContainerControl { get; protected set; } Sets or returns the container control associated with the property this field definition represents. This may or may not be the same control as
InputControl - some field definitions may build a container holding a number of UI elements, only one of which is the actual input control.
ContainerControl is effectively the control which will be inserted into the data entry form. If the control has not been built yet,
BuildInputControl() is called first.
public Control FieldLabel { get; protected set; } Sets or returns the control which represents the label for the input control. If the label hasn't been built yet,
BuildFieldLabel() is called first.
public BaseFieldDefinition.StretchMode StretchMode { get; set; } This property is used to influence the width of the resulting input control when it is added to the data entry form. The effect of this property is up to the
ILayoutStrategy class in use. There are three choices:
Option | Effect |
None | The input control will be sized to the default width for the layout |
Wide | The input control will be wider than normal - the actual width depends on the layout in use. |
Full | The input control will be as wide as the layout allows |
The Stacked layout strategy ignores this property, as all input controls are full-width by default.
Methods
public virtual void BuildInputControl() This virtual method is responsible for creating a suitable input control for editing the property type or types associated with the field definition. Subclasses must override this method to build the required UI elements and controls the field definition represents, and
must set the
InputControl and
ContainerControl properties. If these properties are not set, no control will appear in the form.
public virtual void BuildLabelControl() This virtual method is responsible for creating the field label control which will be displayed alongside the input control. The labels test will be the contents of the
Title property, or if
Title is empty then a
Humanizer'ed form of
PropertyName . Subclasses must override this method to build the required UI controls for a label, and
must populate the
FieldLabelControl property.
The default is a Label control whose Target is the
InputControl , containing a TextBlock whose text is the
Title property (a TextBlock is used to allow word-wrapped labels).