Using MS ReportViewer in WPF - 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.

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

Winforms toolbox tools for WPF

I'm new to WPF and I'm wondering is there anyway to have elements from Winforms toolbox in WPF. I mean the Winforms toolbox has a lot of elements and they're not present in WPF toolbox. for example something like PerformanceCounter in Winforms toolbox is not found in WPF toolbox.
thanks in advance
There are some controls that didn't get represented in WPF, but you can use WindowsFormsHost. As the name indicates, it's purpose is to host the Windows Forms elements.
Walkthrough: Hosting a Windows Forms Control in WPF
I would add that things like PerformanceCounter you can use in code, rather than placing it on a form. Other elements which do have a UI purpose can be placed inside a WindowsFormsHost control. I do this with ReportViewer -- it's a Windows Forms control that has no WPF equivalent.

WPF forms+ Winforms in MDI

We have an application which is using winforms. Now we want to upgrade it.
We are planning to use some WPF forms and some old winforms. and we also need to use MDI.
From MDIParent we need to open both winforms and WPF forms. And these forms need to be in tile format. I got to know that WPF doesn't support MDI.
Is there any other way to achieve this?
Using AvalonDock, can we display the forms in tiles format also. I know that it display in Dockable format.
why you want to upgrade your application to wpf and still use some of your old winforms and the mdi concept any further?(i dont like mixup both:))
for quick and dirty what about using your winform app and integrate wpf in it - if you want/have to?
EDIT:
if you want your WinForms in Wpf you can use
<WindowsFormsHost />
It should work with Avalon too. Here is an example for WindowsFormsHost.

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).

Resources