Skip to main content

Data binding

A QWidget binding is a source → 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

Parameters: 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

Read-only snapshots include 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.
Built-in types are documented in Converters: String / Number / Bool / DateTime / Json / Format / Map / BoolToVisibility / Upper / Lower / Join / Script.

ConverterParameter

ConverterParameter overrides the converter’s default Format:

ConvertBack

With Mode="TwoWay", target changes call ConvertBack. Supported controls:
  • TextBox
  • CheckBox
  • Slider
The write-back target is the Inputs.<Name> binding path; if the path is not Inputs.*, the control Name is used. Returning undefined from ConvertBack skips the write-back.

MultiBinding

  • Paths is separated by |.
  • Multi-value converters receive a values array.
  • Join joins 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 from As.
  • {Index}: 0-based current item index.
  • Nested lists shadow Item / Index.
  • List.Items must 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 { completes Data / Resources / Inputs / Results / Children / Size / State.
  • Typing {Binding completes paths.
  • Converter= completes converter names defined in the current XML.
  • Converter names and ConverterParameter are 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.Path do not support runtime binding; use {Inputs.*} for dynamic sources.
  • A misspelled converter fails parsing with unknown Converter.
  • OneWay controls do not write back; declare Mode="TwoWay" for two-way inputs.
  • MultiBinding Paths uses |, 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.Url does not participate in runtime binding; dynamic sources use limited Inputs / Data forms.
  • Raw < in XML attributes must be written as &lt;.
  • There is no Binding.DoNothing; return undefined from ConvertBack to skip a write-back.