Skip to main content

Converters

A converter sits between a binding source and target to format, coerce, or write back values.

Define converters

Use in bindings

  • Converter references a Converter.Name in the current XML
  • ConverterParameter is optional and overrides the converter’s Format
  • Mode: OneWay (default) / TwoWay / OneWayToSource
  • Existing {Data.foo} and {Inputs.foo} shorthand remains valid

MultiBinding

Paths is separated by |. Script converters receive a values array. Built-in converters use the first value, except Join which joins all values.

Built-in types

Script converters

Script arguments:
  • value: single input
  • values: array of inputs
  • parameter: ConverterParameter
  • targetType: target type string
  • culture: current locale
  • scope: current binding scope
Convert is required; ConvertBack is optional. A script error returns an empty value and does not break rendering. Script converters in remote widgets are executable content and participate in remote-update confirmation. Do not perform network I/O or heavy work in a converter.

ConvertBack

Two-way input controls (currently TextBox and CheckBox) call ConvertBack on change. If the converter has no ConvertBack or returns undefined, the write-back is ignored.

Limits

  • Converters run synchronously; do not perform I/O or network work in Convert
  • Format handles numbers; use DateTime for dates
  • BoolToVisibility returns the strings Visible / Collapsed