Report Viewer in WPF - wpf

I have a WPF project and I need to preview a crystal report. Is it possible to do this?
I can't find a report viewer control in WPF project.
thanks

You can use CrystalReportViewer of windows form with Windows form interop technology to add the viewer to your WPF applicaion.
see WindowsFormsHost Class

Related

SSRS. Reports seem corrupted within the report viewer

I have a WPF application using server side SSRS reports. I'm using the WPF WinFormsHost control, embedding the winforms report viewer control, to display the reports.
On about 20 development pc's and client pc's everthing works ok. The problem is that in a new clients office, on 2 pc's only, the reports seem to be corrupted when viewing within the report viewer. (They print out fine)
Table data is ok, but header data field values are missing. Has anybody experienced this? I'm at a complete loss as to why on these 2 machines data seems to be missing in the report viewer.
Any help would be greatly appreciated.
The Winforms Report Viewer control is not designed to be embedded inside WPF application. You can use WindowsFormsHost Winforms control to host Report Viewer inside your WPF Application, but the data binding of the ReportViewer has to be handled programmatically, because the ReportViewer control will not have knowledge of WPF's Window datasource at all.
This is a sample walkthrough article of embedding Windows Forms control inside WPF: https://msdn.microsoft.com/en-us/library/ms750944.aspx

how to add a WPF dialog to a Winforms project

I am using Visual Studio 2008 targeting .net 3.5 framework. I need to add a WPF dialog to a Winforms project. I was thinking that by adding reference to PresentationCore, PresentationFramework and WindowsBase.dll and copying a WPF dialog from a test WPF project to the WinForms project in question should do the trick, but after that when I try to open in designer a WinForms dialog studio just crashes and closes.
So basically the question is how to add a WPF dialog to a WinForms project?
Thanks
Create the dialog as a WPF UserControl Library. Add it to the Windows Form application by using Project->Add Existing Item. Add an ElementHost component to the Windows Forms form. Set the HostedContent of the ElementHost to the WPF User Control.
This link may help you:
http://msdn.microsoft.com/en-us/library/system.windows.forms.integration.elementhost.aspx

WPF - view and RDLC report file

I have an extensive WPF application and I now want to incorporate some reports. I understand how to create the reports with RDLC but what about viewing them? Ideally, I'd like to use the DocumentViewer but I don't think that's one of the supported file types. Some articles have suggested using the ReportViewer, but I do not have that as a control in my IDE (VS Pro 2008).
Is there a way to "convert" RDLC to XPS and then use the DocumentViewer or what is the best way for a WPF application to view an RDLC report?
The MicrosoftReportViewer control is a Windows Forms control. You can use the WindowsFormsHost control to "host" the report viewer control in WPF, as documented here.
Take a look at the Open-Source .NET WPF Reporting Engine on codeplex

What is the best way to use a SSRS report viewer in a WPF application using MVVM

I have a WPF application using MVVM. I have some user controls that show some SSRS reports in a ReportViewer control hosted within a windows forms host control.
The User Control has a simple combobox where the user selects a criteria and therefore the report satisfying this criteria will be loaded, its data fetched from the database and then the report is shown to the user.
What is the best approach to implement such scenario in WPF using MVVM?
Look at this answer
He is creating the WindowsFormsHost and ReportViewer in the ViewModel
WindowsFormsHost windowsFormsHost = new WindowsFormsHost();
reportViewer = new ReportViewer();
windowsFormsHost.Child = reportViewer;
this.Viewer = windowsFormsHost
and then using a ContentPresenter to display it
<ContentPresenter Content="{Binding Viewer}" />
Unfortunately, there is no native WPF Report Viewer control with similar functionality and there will not be one in .Net 4.0 (according to Jamie Rodriguez at Microsoft).

Using MS ReportViewer in WPF

I'm about to start using the MS ReportViewer in a WPF application by placing the ReportViewer in a WindowsFormsHost.
Is this the correct approach? What is the best way of designing the reports as you cannot use the ReportViewer at design time in a WindowsFormsHost.
Is it best to create an RDL report in SQL Server and then convert it to an RDLC or maybe to create a new Winforms app to create an RDLC file in a WinForms framework and then copy it to the WPF app.
I will need to filter the reports via dropdowns so there's that aspect to consider too. If anyone out there is already using ReportViewer in WPF I would appreciate some feedback on the best approach.....Many thanks.
Yes, that works, I am using the WindowsFormsHost in a wpf project to wrap the ReportViewer.
In the ViewModel I am creating the WindowsFormsHost and the ReportViewer:
WindowsFormsHost windowsFormsHost = new WindowsFormsHost();
reportViewer = new ReportViewer();
windowsFormsHost.Child = reportViewer;
this.Viewer = windowsFormsHost
and in the View I am using a ContentPresenter to display it, by binding to the Property that holds the WindowsFormsHost.
<ContentPresenter Content="{Binding Viewer}" ...
We're using the Business Intelligence Studio (which is an Visual Studio 2008 with templates for editing reports) for report creation. http://msdn.microsoft.com/en-us/library/ms173767.aspx
Take care,
Martin
We've definitely had success just using the WindowsFormsHost. I haven't been involved in creating the RDLC files themselves, but I believe they were designed (as you say) in a WinForms project and then copied across.
Note that if you don't need local reports you can use a WPF Frame control and point it at the URL of the server-based report (it renders it like a web browser would). This works really well for us too.
Please note that you can use both WPF-Windows and Windows-Form-Windows in the same application.
So you can avoid using WindowsFormsHost if you put the ReportViewer in a seperate Windows-Forms-Window that you open from your WPF-Window with ShowDialog.
Then you can use the ReportViewer also at design time.

Resources