MindFusion.Reporting for Silverlight Programmer's Guide
Running, Laying Out and Rendering

Processing

In order to use existing reports in any way they need to be processed by calling their Run method. Calling this method results in the creation of various internal structures corresponding to the data the report is bound to. If the source data or the report design change in any way, the report needs to be rerun.

Laying out

Once the report is run, it can be laid out on target pages of specific sizes by calling its Layout method, passing as arguments the size of the paper to layout on and the paper margin. Both size and margin are expressed in device independent pixels (1/96-th of an inch). The following code lays out the report on a standard A4 paper format with 0.5 inch margin:

C#  Copy Code

ReportLayout layout = report.Layout(
    new Size(8.5 * 96, 11 * 96), new Thickness(0.5 * 96),
    MindFusion.Reporting.PageOrientation.Portrait);

Visual Basic  Copy Code

Dim layout = report.Layout( _
    New Size(8.5 * 96, 11 * 96), New Thickness(0.5 * 96), _
    MindFusion.Reporting.PageOrientation.Portrait)

The result of report layout is encapsulated in a ReportLayout object, which can be manipulated independently of the source report. The same report can be laid out multiple times (on papers of different sizes and orientations, for example) without having to run it over and over again. Its important to note however, that rerunning a report will invalidate all its current layouts. Performing any operation on an invalid layout will result in an InvalidOperationException.

Rendering

Once the report is laid out, we can render its pages using a IRenderTarget object. The following code illustrates how to render a report to a Silverlight Canvas object using the CanvasRenderTarget class. The code assumes that canvas is a variable identifying the Canvas - target of the rendering operation.

C#  Copy Code

CanvasRenderTarget renderTarget = new CanvasRenderTarget(canvas);
for (int i = 0; i < layout.PageCount; i++)
    layout.RenderPage(i, renderTarget);

Visual Basic  Copy Code

Dim renderTarget As New CanvasRenderTarget(canvas)
For i = 0 To layout.PageCount - 1
    layout.RenderPage(i, renderTarget)
Next i