MindFusion.Reporting for Silverlight Programmer's Guide
Using Expressions in Label Texts

You can embed expressions within the text of Label elements by enclosing the expression in square brackets. The following example shows the text of a label with a function call expression embedded within it:

Example  Copy Code

The date and time now is: [Now()]

The expression will be evaluated when the report, containing the label is processed by a call to its Run method. Once the expression is evaluated, its string representation is inserted at its place in the text. In the above example, when the label is displayed, the result will be similar to the following: "The date and time now is: 12/15/2000 1:05:11 PM".

Formatting

By default the result from the evaluation of an embedded expression is formatted to a string through a call to its ToString method. It is also possible to apply custom formatting as illustrated by the following example:

Example  Copy Code

The date and time now is: [Now() @ "d"]

The above example will format the date received as a result of the expression evaluation using short date format. The result will be similar to the following: "The date and time now is: 12/15/2000".

Generally, you can apply any string, which would be a valid format string for the ToString method of the expression evaluation result. The following example illustrates how you can apply formatting to an expression, which evaluates to a number. The example assumes that Price is a identifier which evaluates to a double value.

Example  Copy Code

Cost: [Price @ "$#,##0.00"]

Specifying culture

When applying formatting to an expression, the current culture is used by default. The following example will produce text similar to "16 Jan" when evaluated on machines with regional settings set to en-US or similar:

Example  Copy Code

[Now() @ "dd MMM"]

Evaluating the example is dependent on the current culture however and may yield unexpected results if the current culture is not the one expected. To explicitly specify the culture, use the following syntax:

Example  Copy Code

[Now() @ "dd MMM" : "en-US"]

This will force the expression to always be evaluated with the specified culture regardless of the current regional settings.