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.
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:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxrudex="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesignerextensions"
<!---->
<dxg:TableView>
<dxmvvm:Interaction.Behaviors>
<dxrudex:GridReportManagerServicex:Name="CourseCollectionViewReportService"/>
</dxmvvm:Interaction.Behaviors>
</dxg:TableView>
...then attach ReportManagerBehavior to a Ribbon item and bind its Service property to GridReportManagerService:
xmlns:dxmvvm="http://schemas.devexpress.com/winfx/2008/xaml/mvvm"
xmlns:dxrudex="http://schemas.devexpress.com/winfx/2008/xaml/reports/userdesignerextensions"
<!---->
<dxr:RibbonControl>
<!---->
<dxb:BarSplitButtonItemContent="Reports"ActAsDropDown="True"LargeGlyph="{dx:DXImage Image=Print_32x32.png}"Glyph="{dx:DXImage Image=Print_16x16.png}">
<dxmvvm:Interaction.Behaviors>
<dxrudex:ReportManagerBehaviorService="{Binding ElementName=CourseCollectionViewReportService}"/>
</dxmvvm:Interaction.Behaviors>
</dxb:BarSplitButtonItem>
<!---->
</dxr:RibbonControl>
=========================
We'd love to hear your thoughts on these new features. Let us know what you think.