Data binding
A QWidget binding is asource → converter → target pipeline. Sources include data sources, resources, input controls, function results, command results, nested widget state, and widget size.
Bindings are read-only by default. Input controls with Mode="TwoWay" write target changes back to Inputs through ConvertBack.
Two forms
Shorthand
{path}is the interpolation marker.- A string containing only one binding preserves the original type (number, boolean, object, array).
- Mixed text is converted to a string.
- A missing path yields an empty string.
Explicit Binding
Quote parameters that contain commas:
Path syntax
- Paths are case-sensitive:
{data.Title}differs from{Data.Title}. - Array indexes must be decimal:
Items.0. - Only own object properties are readable;
constructor,prototype, and__proto__are blocked. - A missing path, type mismatch, or unloaded source yields an empty value.
- Property names cannot contain dots; use nested objects instead.
Namespaces
Data
- Named source:
{Data.News.Title}, or directly{News.Title}. - An unnamed source defaults to
Data; its fields merge into{Data.Title}. - Duplicate data source names are rejected by XML validation.
Data.Status.News:Loading/Completed/Error.- With
Async="True", the widget renders first and bindings refresh after loading.
Resources
String / Bool / Number / Json / Binary preserve their types; Binary becomes { Url, Base64, Mime, Size }.
Results
Children
Inputs / Data / Results / Outputs / State.
Size and State
Size.Width / Size.Height are grid columns/rows; Size.PixelWidth / Size.PixelHeight are actual pixels. State.Loading / State.Error are booleans.
Type rules
Exact bindings preserve type, which is useful for:
Converter
A converter transforms values between the binding source and target, including formatting, type coercion, and two-way write-back.String / Number / Bool / DateTime / Json / Format / Map / BoolToVisibility / Upper / Lower / Join / Script.
ConverterParameter
ConverterParameter overrides the converter’s default Format:
ConvertBack
WithMode="TwoWay", target changes call ConvertBack. Supported controls:
TextBoxCheckBoxSlider
Inputs.<Name> binding path; if the path is not Inputs.*, the control Name is used. Returning undefined from ConvertBack skips the write-back.
MultiBinding
Pathsis separated by|.- Multi-value converters receive a
valuesarray. Joinjoins all values.- Current input controls write MultiBinding changes only to the first path.
Bindings in action parameters
Arguments is parsed as JSON first, then string values are deeply interpolated; a whole-string binding preserves the original type.
List scope
{Item.*}: current item; the variable name comes fromAs.{Index}: 0-based current item index.- Nested lists shadow
Item/Index. List.Itemsmust be an array; an object renders an empty list.
Refresh and lifecycle
- Bindings recompute with the latest scope after data changes.
Async="True"does not block first paint; bindings refresh after loading.Data.Status.*supports loading and error placeholders.- Remote updates confirm only executable-content changes; ordinary data/text/layout changes are silent.
Editor support
- Typing
{completesData/Resources/Inputs/Results/Children/Size/State. - Typing
{Bindingcompletes paths. Converter=completes converter names defined in the current XML.- Converter names and
ConverterParameterare validated during XML parsing.
Common mistakes
- Path case is significant:
{data.Title}differs from{Data.Title}. - Bindings are empty while data loads; use
If Test="{State.Loading}"for a placeholder. - Static
Data.Url/Data.Pathdo not support runtime binding; use{Inputs.*}for dynamic sources. - A misspelled converter fails parsing with
unknown Converter. OneWaycontrols do not write back; declareMode="TwoWay"for two-way inputs.MultiBindingPathsuses|, not commas.- Script converters run synchronously and must not perform network I/O; remote scripts require executable confirmation.
Limits
- Paths only read object properties; no method calls, expressions, or indexer syntax.
- Bindings evaluate synchronously; converters must not perform I/O or heavy work.
- Static
Data.Urldoes not participate in runtime binding; dynamic sources use limitedInputs/Dataforms. - Raw
<in XML attributes must be written as<. - There is no
Binding.DoNothing; returnundefinedfromConvertBackto skip a write-back.