WPF Grid-Based Report Generation (Coming soon in v15.2)

Thinking Out Loud
13 November 2015

In our never-ending quest to make reporting easier (and more flexible) for developers and end-users alike, v15.2 will introduce a new WPF Grid-based report generation option. As you can see from the screenshot below, this new option gives your power users a way to customize output and hopefully go a long way to reducing the number of custom reports you'll have to create over the life of your app.

WPF Grid-based Report Generation

With just a few lines of code, you can invoke the DevExpress WPF Report Designer at runtime from the Grid Control and create reports based on its data.

public static void ShowDesigner(IGridViewFactory<ColumnWrapper, RowBaseWrapper> factory)    {
    var report = new XtraReport();
    ReportGenerationExtensions<ColumnWrapper, RowBaseWrapper>.GenerateFrom(report, factory);
    var reportDesigner = new ReportDesigner();
    reportDesigner.Loaded += (s, e) =>    {
        reportDesigner.OpenDocument(report);
    };
    reportDesigner.ShowWindow(factory as FrameworkElement);
}

To make things as easy as possible, we've added two behaviors that allow you to incorporate Grid-based report generation in your app when using our WPF Ribbon control:

  • DevExpress.Xpf.Reports.UserDesigner.Extensions.ReportManagerBehavior
  • DevExpress.Xpf.Reports.UserDesigner.Extensions.GridReportManagerService.

Here's how it works...first, attach the GridReportManagerService to a TableView:

xmlns:dxg="http://schemas.devexpress.com/winfx/2008/xaml/grid"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxrudex="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesignerextensions"
<!---->
<dxg:GridControl ... >
    <dxg:GridControl.View>
        <dxg:TableView ... >
           <dxmvvm:Interaction.Behaviors>
               <dxrudex:GridReportManagerService x:Name="CourseCollectionViewReportService" />
           </dxmvvm:Interaction.Behaviors>
        </dxg:TableView>
    </dxg:GridControl.View>
</dxg:GridControl>

...then attach ReportManagerBehavior to a Ribbon item and bind its Service property to GridReportManagerService:

xmlns:dxr="http://schemas.devexpress.com/winfx/2008/xaml/ribbon"
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxrudex="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesignerextensions"
<!---->
<dxr:RibbonControl ... >
    <!---->
    <dxb:BarSplitButtonItem ... >
        <dxmvvm:Interaction.Behaviors>
            <dxrudex:ReportManagerBehavior Service="{Binding ElementName=CourseCollectionViewReportService}" />
        </dxmvvm:Interaction.Behaviors>
    </dxb:BarSplitButtonItem>
    <!---->
</dxr:RibbonControl>

WPF Grid-based Report Generation

=========================

We'd love to hear your thoughts on these new features. Let us know what you think.




Free DevExpress Products - Get Your Copy Today

The following free DevExpress product offers remain available. Should you have any questions about the free offers below, please submit a ticket via the DevExpress Support Center at your convenience. We'll be happy to follow-up.
No Comments

Please login or register to post comments.