Data Binding
Data Binding is a mechanism for synchronizing data between objects and UI elements to display data and affect the behavior of controls. Usually, data is passed from a data object (such as a customer list) to a control on the user interface (such as a table) and vice versa. If this mechanism is used, a loop does not have to be used for each object in the dataset, but the control identifies how many objects exist and adjusts itself automatically. If changes are made by the user in the control, they can be restored to the dataset.
The name
attributes of the elements are used for data binding.
Example Data Binding:
<DetailComponent name="DetailExample" path="DetailExample" displayName="Detail example">
<Properties>
<Property name="Example" type="String" />
<Property name="Example2" type="Complex">
<Property name="Internal" type="String" />
<Property name="Visible" type="Boolean" />
</Property>
</Properties>
<FlowLayout>
<Label value="#Example" />
<Checkbox checked="#Example2.Visible" displayName="Visible" />
<Label value="#Example2.Internal" visible="#Example2.Visible" />
</FlowLayout>
</DetailComponent>
The above example shows the usage of data binding. The value
attribute of the Label
control allows data binding, so the name of the property can be used with a leading # character. The path mechanism is used to guarantee access to subproperties of List
or Complex
properties. A dot (.
) is used as a separator between path segments.
One of the properties (Example2.Visible
) is used to define if the checkbox is checked and as attribute visible
of the second label. This makes it possible to control the visibility of the second label using the checkbox: If the value of the checkbox changes (selected or not selected), the data binding mechanism updates it at every point.
If a #
character is to be used in a data binding expression, the character must be escaped. A backslash (\
) is used as escaping character.
Example: \#123456