Simple Arithmetic:
Suppose you want to display
taxes due on a certain amount. Using traditional bindings, you would need a
converter to calculate the tax amount. Using C1Binding, you can calculate
the amount using a simple expression:
<TextBlock
Text="{c1:C1Binding Expression='Amount * 8.5%'
}"
Combining Values:
Suppose you want to extend the
scenario above and display the total amount in addition to the tax amount. You
could do that using several TextBlock elements, but it would be more
efficient to use a single TextBlock and a C1Binding
based on the CONCATENATE function:
<TextBlock
Text="{c1:C1Binding Expression=
'CONCATENATE(Amount,
| Tax: |, Amount * 8.5%' }"
Formatting Values:
C1Binding
and regular Binding objects have a StringFormat property that you
can use to control the format of bound values. If your binding expression
requires formatting several parts of the output, you can use the TEXT function
as follows:
<TextBlock
Text="{c1:C1Binding Expression=
'CONCATENATE(TEXT(Amount,
|c|), | Tax: |, TEXT(Amount * 8.5%, |c|))' }"
Conditional Formatting:
Suppose you want to
create a user interface where amounts greater than a certain value are displayed
in bold and red. You can accomplish this using the IF function, which performs
conditional logic:
<TextBlock
Text="{c1:C1Binding Expression='Amount',
StringFormat='c'}"
Foreground="{c1:C1Binding Expression='if(Amount >
1000, |red|, |black|)' }" />
FontWeight="{c1:C1Binding Expression='if(Amount >
1000, |bold|, |normal|)' }" />