How to show a preview in WPF ListLabelViewerControl

Hi,

i want to show directly a preview of a report in an application window (WPF) (without LL-Preview-Window). I have read that combit.Reporting.Wpf.ListLabelViewerControl should do the trick, but i didn´t get to work. ll.Print() always opens the LL-Preview-Window and the ListLabelViewerControl remains empty.

This is my method:

       private void vorschauBtn_Click(object sender, RoutedEventArgs e)
        {
            using (ListLabel ll = new ListLabel())
            {
                ll.DataSource = CreateDatasource();
                ll.AutoShowPrintOptions = false;
                ll.AutoShowSelectFile = false;
                ll.AutoProjectFile = @"..\..\..\Report.lst";
                ll.PreviewControl = llViewer; // ListLabelViewerControl in XAML
                ll.AutoDestination = LlPrintMode.PreviewControl;

                ll.Print();
            }
        }

Any ideas what i´m doing wrong?

Best regards,
Benjamin

If you want to use the ListLabelViewerControl, you need to create a preview file first and then assign the path to its FileName property. You can do so by following the advice in Export Without User Interaction Using OCX / VCL or .NET Component and use LlExportTarget.Preview in your ExportConfiguration.

Something along the lines of

ExportConfiguration cfg = new ExportConfiguration(LlExportTarget.Preview, @"c:\temp\export.ll", "export.lst");
LL.Export(cfg);
llViewer.FileName = @"c:\temp\export.ll";

should do the trick.

If you’d like to print directly to a WPF preview window and use incremental preview and interactive features like drill-down etc, you need to use the EnhancedViewerControl WPF class. See the DataBindingSample for WPF for an example. Basically, this class offers a PreviewControl property that can be assigned to the ListLabel object in your code above like so:

ll.PreviewControl = enhancedPreviewControl.PreviewControl;

Does that help?

Great, many thanks. It seems to be crucial to set height and width of the EnhancedViewerControl!? Otherwise the control is not visible.

1 Like

Im not exactly sure what you mean in detail. But within our samples the control is placed within DockPanel/Grid and uses its width and height. How the controls ist placed within your XAML?

© combit GmbH