ExpressionConverter

Build 1501 on 14/Nov/2017  This topic last edited on: 21/Mar/2016, at 18:34

This is available in version 1.4 or newer.

The ExpressionConverter is a math converter that in directory styles for both the web and windows applications displays the results of mathematical operations on one or more bound value.

The ExpressionConverter is a multi-value converter for use with MultiBinding bindings. The following example displays an approximate column inches value based on the number of characters in a story:

ConverterParameter="{}{0}/29.5:{0:0.00} in" > 

The ConverterParameter value specifies both the mathematical expression and the format of the resulting value separated by a colon.

The values passed to the expressions must by integer or floating point values, and are evaluated using floating point arithmetic.

The expression uses {n} placeholders, where n is a zero-based index into the Binding elements contained in the associated MultiBinding. The example above has a single Binding for story.nChars and is referenced in the expression using {0}.

Additional Binding values can be added to the MultiBinding and are referenced using the appropriate {n} placeholder in the expression.

Note also the use of {} at the start of the ConverterParameter which escapes the standard XAML markup interpretation of {.