Save time and write cleaner XAML

Never write another converter again with ComponentOne Binding Expressions™ for WPF. Save time and write cleaner XAML by taking advantage of Binding Expressions’ rich, inline expression syntax. Concatenate strings, compute formulas, and apply if/else logic directly in your binding statements without the need for code-behind converters.

Logical and Arithmetic Operators

Perform simple arithmetic and mathematical functions in your bindings. You can use any of the common logical (=, >, <, <>, >=, <=) and arithmetic (+, -, *, /, ^) operators. You can also group expressions using parentheses. For example, “Amount * 8.5%” returns the value of the Amount property times 0.085:

<TextBlock Text="{c1:C1Binding Expression='Amount * 8.5%'}" />

Formatting Values

Binding objects have a StringFormat property that you can use to control the format of bound values. For example, the following XAML snippet applies a currency format to the evaluated expression:

<TextBlock Text="{c1:C1Binding Expression='Amount * 8.5%', StringFormat='c'}" />

Conditional Formatting

You can apply conditional formatting to your bound values using the IF function, which performs conditional logic. For example, the following XAML snippet formats values greater than 1,000 to appear bold:

Text="{c1:C1Binding Amount}"
FontWeight="{c1:C1Binding Expression='IF(Amount &gt; 1000, |bold|, |normal|)' }" />

Combining Values

You can use text functions to accomplish common scenarios like replacing characters, converting to upper or lower case, or combining multiple values into one. For example, you can use the CONCATENATE function to display the total amount in addition to the taxed amount with the following XAML snippet:

Text="{c1:C1Binding Expression=
'CONCATENATE(Amount, & quot; Tax: & quot;, Amount * 8.5%' }" />

Use Quotes without Breaking Your XAML

Use quotes in your binding expressions without breaking your XAML. Binding Expressions for WPF support inline quotes in two forms: & quot; or use of the pipe (|) character. For example, the XAML snippet above could be rewritten with the following for more readability:

Text="{c1:C1Binding Expression='CONCATENATE(Amount, | Tax: |, Amount * 8.5%' }" />

Clean and Expressive XAML

By using Binding Expressions, your XAML will be much cleaner and more expressive — as well as 100% self-contained. You don't need any external converters referenced from elsewhere in your solution.

Parse and Evaluate Expressions

Binding objects use the CalcEngine class to parse and evaluate expressions. CalcEngine is a public class, and can be used independently to parse strings into Expression objects or to parse strings to evaluate resulting expressions. For example, you could have a calculated TextBox that allows users to type expressions, like 4 + 16, and have them evaluated when the control loses focus by using the CalcEngine’s Evaluate method.