Class FormComponent<TProperties, TValue>
Represents a base class for a form component. Inherit this class to define a custom form component.
public abstract class FormComponent<TProperties, TValue> : FormComponent where TProperties : FormComponentProperties<TValue>, new()
Type Parameters
TPropertiesProperties type of the form component.
TValueValue type of the form component.
- Inheritance
-
objectFormComponent<TProperties, TValue>
- Derived
- Inherited Members
- Extension Methods
Remarks
Properties which are expected to have automatically bound values after form submit, have to be annotated with BindablePropertyAttribute.
Constructors
FormComponent()
Initializes a new instance of the FormComponent<TProperties, TValue> class.
protected FormComponent()
Properties
BaseProperties
Gets the form component's properties as its base type.
public override FormComponentProperties BaseProperties { get; }
Property Value
Properties
Gets the form component's properties.
[ValidateNever]
public TProperties Properties { get; protected set; }
Property Value
- TProperties
Methods
GetObjectValue()
Gets the value of the form component. The GetValue() method can be used directly to obtain the typed value.
public override object GetObjectValue()
Returns
- object
Returns the value of the form component.
GetValue()
Gets the value of the form component. Implement in a subclass to return value of a desired property. Method can also be used to return a value composed of multiple properties if required.
public abstract TValue GetValue()
Returns
- TValue
Returns the value of the form component.
LoadProperties(FormComponentProperties)
Loads properties of the form component. The actual properties type must match the PropertiesType.
public override void LoadProperties(FormComponentProperties properties)
Parameters
propertiesFormComponentPropertiesForm component properties to be loaded.
Exceptions
- ArgumentNullException
Thrown when
propertiesare null.- ArgumentException
Thrown when
propertiesdo not match the PropertiesType.
SetObjectValue(object)
Sets the value of the form component.
The value must be of proper type or an exception is thrown.
The SetValue(TValue) method can be used directly to set the typed default value.
public override void SetObjectValue(object value)
Parameters
valueobjectValue to be set.
SetValue(TValue)
Sets the value of the form component. Implement in a subclass to set value of a desired property. Method can also be used to decompose passed value into several properties rendered in the resulting form component markup.
public abstract void SetValue(TValue value)
Parameters
valueTValueValue to be set.